Reputation: 65
I have these 3 tests:
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using System;
using System.Threading;
namespace FirstTestCase
{
class _04_02_Media
{
class NUnitTest
{
[TestCase(TestName = "04_02_01_Libraries_Add_OnDemand_Video")]
public void Libraries()
{}
[TestCase(TestName = "04_02_02_Replace_OnDemand")]
public void OnDemandReplace()
{}
[TestCase(TestName = "04_02_03_Delete_OnDemand")]
public void OnDemandDelete()
{}
For some reason i cannot understand and is making me go crazy, the "delete" test, the one supposed to be the last, happens second. This is a big deal as the "replace" test, that happens last, uses the deleted video.
Why does it run in this order? Is there anything else i should use to change the order?
Upvotes: 2
Views: 118
Reputation: 9636
Just use order
attribute.
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using System;
using System.Threading;
namespace FirstTestCase
{
class _04_02_Media
{
class NUnitTest
{
[Test, Order(1)]
public void Libraries()
{}
[Test, Order(2)]
public void OnDemandReplace()
{}
[Test, Order(3)]
public void OnDemandDelete()
{}
}
}
}
Upvotes: 2
Reputation: 118937
You can use the Order
attribute to specify the order:
[Order(1)]
public void Test1() { /* ... */ }
[Order(2)]
public void Test2() { /* ... */ }
[Order(3)]
public void Test3() { /* ... */ }
However, you should really try to make sure your tests are self-contained otherwise they can be quite brittle.
Upvotes: 5