This question is locked. New answers and comments are not allowed.
Hi Telerik Team,
My boss would like me to create unit tests that can be started on a windows form button click.
Is there anyway to do this?
Basically I have added a new windows form project called "TheTester" and on a button click run the test. I added the reference to the "TestExample" project and set "TheTester" as the startup project. "TheTester" recognizes "TestExample" until I run the project then somehow loses the reference. (Code below)
Also, is there a way that when I click "Convert all steps to code" then delete the ".aii" file while still keeping the pages.g.vb file intact?
Any assistance would be much appreciated.
My boss would like me to create unit tests that can be started on a windows form button click.
Is there anyway to do this?
Basically I have added a new windows form project called "TheTester" and on a button click run the test. I added the reference to the "TestExample" project and set "TheTester" as the startup project. "TheTester" recognizes "TestExample" until I run the project then somehow loses the reference. (Code below)
Also, is there a way that when I click "Convert all steps to code" then delete the ".aii" file while still keeping the pages.g.vb file intact?
Any assistance would be much appreciated.
Imports ArtOfTest.WebAii.Controls.HtmlControlsImports ArtOfTest.WebAii.Controls.HtmlControls.HtmlAssertsImports ArtOfTest.WebAii.CoreImports ArtOfTest.WebAii.ObjectModelImports ArtOfTest.WebAii.TestAttributesImports ArtOfTest.WebAii.TestTemplatesImports ArtOfTest.WebAii.Win32.DialogsImports ArtOfTest.WebAii.SilverlightImports ArtOfTest.WebAii.Silverlight.UIImports Microsoft.VisualStudio.TestTools.UnitTestingNamespace TestExample1 ''' <summary> ''' Summary description for GoogleTelerikUnitTest ''' </summary> <TestClass()> _ Public Class GoogleTelerikUnitTest Inherits BaseTest#Region "[Setup / TearDown]" Private testContextInstance As TestContext = Nothing ''' <summary> '''Gets or sets the VS test context which provides '''information about and functionality for the '''current test run. '''</summary> Public Property TestContext() As TestContext Get Return testContextInstance End Get Set(ByVal value As TestContext) testContextInstance = value End Set End Property 'Use ClassInitialize to run code before running the first test in the class <ClassInitialize()> _ Public Shared Sub MyClassInitialize(ByVal testContext As TestContext) End Sub Private _pages As Pages Public ReadOnly Property Pages As Pages Get If (_pages Is Nothing) Then _pages = New Pages(Manager.Current) End If Return _pages End Get End Property ' Use TestInitialize to run code before running each test <TestInitialize()> _ Public Sub MyTestInitialize() '#region WebAii Initialization ' Initializes WebAii manager to be used by the test case. ' If a WebAii configuration section exists, settings will be ' loaded from it. Otherwise, will create a default settings ' object with system defaults. ' ' Note: We are passing in a delegate to the VisualStudio ' testContext.WriteLine() method in addition to the Visual Studio ' TestLogs directory as our log location. This way any logging ' done from WebAii (i.e. Manager.Log.WriteLine()) is ' automatically logged to the VisualStudio test log and ' the WebAii log file is placed in the same location as VS logs. ' ' If you do not care about unifying the log, then you can simply ' initialize the test by calling Initialize() with no parameters; ' that will cause the log location to be picked up from the config ' file if it exists or will use the default system settings (C:\WebAiiLog\) ' You can also use Initialize(LogLocation) to set a specific log ' location for this test. ' Pass in 'true' to recycle the browser between test methods Initialize(False, Me.TestContext.TestLogsDir, New TestContextWriteLine(AddressOf Me.TestContext.WriteLine)) ' If you need to override any other settings coming from the ' config section you can comment the 'Initialize' line above and instead ' use the following: ' ' ' // This will get a new Settings object. If a configuration ' // section exists, then settings from that section will be ' // loaded ' ' Settings settings = GetSettings(); ' ' // Override the settings you want. For example: ' settings.DefaultBrowser = BrowserType.FireFox; ' ' // Now call Initialize again with your updated settings object ' Initialize(settings, new TestContextWriteLine(AddressOf this.TestContext.WriteLine)); ' ' ' Set the current test method. This is needed for WebAii to discover ' its custom TestAttributes set on methods and classes. ' This method should always exist in [TestInitialize()] method. SetTestMethod(Me, DirectCast(TestContext.Properties("TestName"), String)) ' ' Place any additional initialization here ' End Sub ' Use TestCleanup to run code after each test has run <TestCleanup()> _ Public Sub MyTestCleanup() ' ' Place any additional cleanup here ' '#region WebAii CleanUp ' Shuts down WebAii manager and closes all browsers currently running ' after each test. This call is ignored if recycleBrowser is set Me.CleanUp() End Sub 'Use ClassCleanup to run code after all tests in a class have run <ClassCleanup()> _ Public Shared Sub MyClassCleanup() ' This will shut down all browsers if ' recycleBrowser is turned on. Else ' will do nothing. ShutDown() End Sub#End Region <TestMethod()> Public Sub GoogleTelerik() 'Launch an instance of the browser Manager.LaunchNewBrowser() 'Navigate to : 'http://google.co.nz/' ActiveBrowser.NavigateTo("http://google.co.nz/") 'Set 'QText' text to 'telerik' Pages.Google.QText.Wait.ForExists(5000) Pages.Google.QText.Text = "telerik" 'Click 'BtnGSubmit' Pages.Google.BtnGSubmit.Click(False) 'Click 'TelerikEmTag' Pages.TelerikGoogleSearch.TelerikEmTag.Click(False) End Sub End ClassEnd Namespace
Public Class Form1
Private Sub RunTest_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RunTest.Click
Dim theTest As New TestExample.TestExample1.GoogleTelerikUnitTest()
theTest.MyTestInitialize()
theTest.GoogleTelerik()
End Sub
End Class