Reputation: 116
I execute them in parallel and it works
I execute them with order (priorities) and it works
when I want to combine priorities + parallelism does not work
example:
assembly: [assembly: LevelOfParallelism(3)]
[TestFixture]
[Parallelizable(ParallelScope.Children)]
public class Tests
{
[Test, Order(1)]
public void Test1()
{
//1
}
[Test, Order(1)]
public void Test2()
{
//2
}
[Test, Order(2)]
public void Test3()
{
//3
}
}
They all run at the same time, it should be 1 and 2, then 3.
NUNIT 3
Upvotes: 1
Views: 1487
Reputation: 22647
You are asking to run your tests in parallel (at the same time), but also asking to run them in order (one after the other). This is impossible, so NUnit is only respecting one of your demands. There are many conflicting attributes and command line options in NUnit. We try to warn you for some of the less obvious conflicts, but we cannot handle every combination.
If you have other tests in the class that you want to run in parallel but still want to respect order on a few, mark the ordered tests with ParallelScope.None.
Upvotes: 2
Reputation: 6042
The OrderAttribute only dictates the point at which a test is started. If you need one test to complete before the next starts, this of course works fine if you are running tests sequentially - but you'll get race conditions (as you've seen) when you start running tests on multiple threads.
It sounds like you're looking for something like the Test Dependency Attribute feature request here: https://github.com/nunit/nunit/issues/51. Feel free to add your thoughts on the issue.
In the meantime - I'd suggest adding the [NonParallelizable]
attribute to this Test Fixture.
Upvotes: 3