AshFowler
AshFowler

Reputation: 13

Is there a way to run multiple test orders in one instance of web browser?

Currently here is how my code looks: This is in NUnit C#

[FixtureLifeCycle(LifeCycle.SingleInstance)]
[TestFixture]
public class xxxxx: xxxxx
{
    private xxxxx xxxxx;

    [SetUp] 
    public void SetUp() 
    {
        xxxxx = new xxxxx(GetDriver());    
    }

    [Test, Order(1)]
    public void test1()

    [Test, Order(2)]
    public void test2()

    [Test, Order(3)]
    public void test3()

    [Test, Order(4)]
    public void test4()
}

I want to try and run these in the same web browser instance, So when test order 1 has finished I want to number 2 to carry on in the same instance and not close my browser and restart.

I've tried the [SingleTearDown] && [SingleStartUp] methods, I've also tried to call test2 inside of test1, this seems to work but doesn't seem best practice.

Upvotes: 1

Views: 64

Answers (1)

Guy
Guy

Reputation: 50809

You are looking for OneTimeSetUp

[FixtureLifeCycle(LifeCycle.SingleInstance)]
[TestFixture]
public class xxxxx: xxxxx
{
    private xxxxx xxxxx;

    [OneTimeSetUp] 
    public void SetUp() 
    {
        xxxxx = new xxxxx(GetDriver());
        
    }

    [Test, Order(1)]
    public void test1()

    [Test, Order(2)]
    public void test2()

    [Test, Order(3)]
    public void test3()

    [Test, Order(4)]
    public void test4()
}

Upvotes: 1

Related Questions