views:

268

answers:

1

I have written a HomePageClass

Imports System
Imports System.Collections.Generic
Imports System.Text.RegularExpressions
Imports System.Text
Imports WatiN.Core

Namespace TestDesign
    Public Class HomePage
        Inherits IE
        Public Const HomePageURL As String = "test"

        Public Sub New()
            MyBase.New(HomePageURL)
        End Sub

        Public Sub New(ByVal instance As IE)
            MyBase.New(instance.InternetExplorer)
        End Sub

        Public ReadOnly Property UserIDField() As TextField
            Get
                Return TextField(Find.ById(New Regex("txtuserName")))
            End Get
        End Property

        Public ReadOnly Property PasswordField() As TextField
            Get
                Return TextField(Find.ById(New Regex("txtPassword")))
            End Get
        End Property

        Public ReadOnly Property ContinueButton() As Button
            Get
                Return Button(Find.ById(New Regex("Submit")))
            End Get
        End Property

        Public ReadOnly Property UserRegistrationLink() As Link
            Get
                Return Link(Find.ByUrl("userregistration.aspx"))
            End Get
        End Property

        Friend Sub Login(ByVal username As String, ByVal password As String)
            UserIDField.TypeText(username)
            PasswordField.TypeText(password)
            ContinueButton.Click()
        End Sub

        'Friend Function GoToUserRegistration() As UserRegistrationPage
        '    UserRegistrationLink.Click()
        '    Return New UserRegistrationPage(Me)
        'End Function
    End Class
End Namespace

And a HomePagetestsClass

Imports System.Threading
Imports NUnit.Framework
Namespace TestDesign

<TestFixture()>_
Class HomePageTests

    <Test()> _
    Public Sub GoToHomePageTest()
        Dim home As New HomePage()
        Assert.IsTrue(home.ContainsText("Welcome"))
        home.Close()
    End Sub

    <Test()> _
    Public Sub Login()
        Dim home As New HomePage()
        home.Login("abc", "def")
        Assert.IsTrue(home.ContainsText("Welcome"))
        home.Close()
    End Sub
End Class

Can anyone plz tell, where I am getting wrong. Just trying to implement a generalised Test Pattern.

+3  A: 

The reason your tests are being ignored is that all TestFixture classes must be public. If you do not specifically state a level of visibility, then .NET assumes your class should only be visible within your assembly (Friend aka Internal in C#). Since the NUnit GUI is not part of your assembly, it cannot create your TestFixture. Simple change the line:

Class HomePageTests

to:

Public Class HomePageTests

and you'll be good to go.

TRayburn
Thanks. yes Working fine now. by making it public
sam