I’m trying to write some Selenium tests with NUnit and doing my best to keep a clean test design (testing one thing for each test). So I got something like this
[TestFixture]
public class SomeTest
{
IWebDriver driver;
[Setup]
public void Setup()
{
driver = new InternetExplorerDriver();
}
[Test]
public void Test1()
{
}
[Test]
public void Test2()
{
}
[Teardown]
public void Teardown()
{
driver.Close();
}
}
Now this is fine, but things get insanely slow as the number of tests increase. Starting and stopping the entire browser for each test is a bottleneck.
Any way to keep the browser open until the last test? Or perhaps a better approach/design?
In order to only bring up one browser per fixture you can use [TestFixtureSetUp] [TestFixtureTearDown] instead of [SetUp] and [TearDown]:
Of course this does not help across fixtures, but could still give some performance gain.