Unable to run script using Nunit

2 posts, 0 answers
  1. Vidya
    Vidya avatar
    3 posts
    Member since:
    Jun 2013

    Posted 25 Jun 2013 Link to this post

    Script is not executed when ‘Nunit’ item is added to ‘Unit Test Project’

    Please find below steps

    1. 1. I have created new project by selecting C# template i.e( Unit Test Project)
    2. 2. Deleted by default added ‘Class1.cs’ file
    3. 3. Installed Nunit in system
    4. 4. Added the new item to the project  i.e Nunit  (Visual C# Items->Test->TelerikTestingFramework2012.2->Web->Nunit)
    5. 5. Tried to add ‘NUnit Extension. dll’ file but didn’t find dll file link provided in ‘Telerik User guide’
    6. 6. Hence downloaded ‘NUnit Extension. dll’ from other sites and placed in ‘C:\Program Files (x86)\NUnit 2.6\bin\addins’ folder
    7. 7. But in ‘NUnit’ , Tools—‘Addins’, I didn’t find any addin
    8. 8. Right click on the sample script and clicked on ‘Run Test’

    9. Script is not at all executing  and not even browser is invoked

    Sample Script:

    using System;

    using System.Collections.Generic;

    using System.Linq;

    using System.Text;

    using ArtOfTest.WebAii.Controls.HtmlControls;

    using ArtOfTest.WebAii.Controls.HtmlControls.HtmlAsserts;

    using ArtOfTest.WebAii.Core;

    using ArtOfTest.WebAii.ObjectModel;

    using ArtOfTest.WebAii.TestAttributes;

    using ArtOfTest.WebAii.TestTemplates;

    using ArtOfTest.WebAii.Win32.Dialogs;

    using ArtOfTest.WebAii.Silverlight;

    using ArtOfTest.WebAii.Silverlight.UI;

    using NUnit.Framework;

    using Core = NUnit.Core;

    //using Microsoft.VisualStudio.TestTools.UnitTesting;

    namespace Sampe1

    {

        /// <summary>

        /// Summary description for TelerikNUnitTest1

        /// </summary>

        [TestFixture]

        public class TelerikNUnitTest1 : BaseTest

        {

            #region [Setup / TearDown]

            /// <summary>

            /// Initialization for each test.

            /// </summary>

            [SetUp]

            public void MyTestInitialize()

            {

                #region WebAii Initialization


                Initialize(false, new TestContextWriteLine(Console.Out.WriteLine));

               

                #endregion

          

            }

             [TearDown]

            public void MyTestCleanUp()

            {

                #region WebAii CleanUp

                // Shuts down WebAii manager and closes all browsers currently running

                this.CleanUp();

                #endregion

            }


            [TestFixtureTearDown]

            public void FixtureCleanup()

            {

                ShutDown();

            }

            #endregion

            [Test]

            public void SampleWebAiiTest()

            {

                // Launch a browser instance

                Manager.LaunchNewBrowser(BrowserType.InternetExplorer);

                // Navigate the active browser to www.wikipedia.org

                ActiveBrowser.NavigateTo("http://www.wikipedia.org/");

                // Find the wikipedia search box and set it to "Telerik Test Studio";

                Find.ById<HtmlInputSearch>("searchInput").Text = "Telerik Test Studio";

                // Click the search arrow button

                Find.ByName<HtmlInputSubmit>("go").Click();

                // Validate that search contains 'Telerik Test Studio'

               // Assert.IsTrue(ActiveBrowser.ContainsText("Telerik Test Studio"));

                //Read more here:

                //http://www.telerik.com/automated-testing-tools/support/documentation/user-guide/write-tests-in-code/intermediate-topics/element-identification/finding-page-elements.aspx

            }

        }

    }

    Please guide me how to run script using Nunit(Telerik Test Framework) in 'Unit Test Project'

  2. Velin Koychev
    Admin
    Velin Koychev avatar
    88 posts

    Posted 26 Jun 2013 Link to this post

    Hello Vidya,

    You can try following the steps that are described in this article

    1) Add the new item to the project - NUnit  (Visual C# Items->Test->TelerikTestingFramework2012.2->Web->NUnit)
    2) Add references to the NUnit dll's nunit.core.dll and nunit.framework.dll
    3) If you have NUnit Test Adapter already installed, you should be now able to run the test successfully.

    I have recorded a short video to demonstrate you how to do this. 

    Regarding the NUnit Extension dll, you need to download the NUnit Extension source from here. You have to compile the sources against your version of NUnit, however you won't be able to do this if you use the most current NUnit version (2.6). The reason is that in the newer versions the  RunTestMethod(TestResult) is now private and cannot be overridden. You can try using an older version like 2.5.7 to make it work.
    You need to have this dll if you want to use Unit Testing Web Extensions. But you should be able to run sample test like this without any issue. 

    I hope this helps. 

    Regards,
    Velin Koychev
    Telerik
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
Back to Top