简体   繁体   中英

How to adjust speed of nunit test cases in C# or in nunit interface?

I have used selenium IDE and created test cases. I have converted them to Nunit with C# and I started running testcases. How can I adjust speed of running test cases using either nunit interface or C# code. (In selenium ide interface, I could able to adjust speed so as to run test case slowly.)

You could add a TestFixtureSetup to each TestFixture . The example below should run before each test and cause a 5 second wait:

[TestFixture]
public MyTests()
{
    [TestFixtureSetUp]
    public void Init()
    {
        System.Thread.Sleep(5000);
    }

    ...
}

One of these links ought to work:

similar SO question:

selenium webdriver manage speed?

Forum result for selenium ( http://seleniumforum.forumotion.net/t376-to-control-of-speed-execute-in-selenium-rc ):

[SetUp]
public void SetupTest()
{
selenium = new DefaultSelenium("localhost", 4444, "*iexplore", URL");
selenium.Start();
selenium.SetSpeed("1000");

}

I've been looking into this quite a lot over the past few days. By far the simplest way to solve this is to create a driver property, rather than a variable and add a wait to the get.

  private IWebDriver _driver;
    public IWebDriver driver
    {
        get{ Thread.Sleep(500);
            return _driver;
        }

        set
        { _driver = value; }
    }

This means that anytime your driver is requested, which is anytime you do anything in the browser, it will slow it down by the specified amount.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM