Skip to main content

Ordering Tests

By default, TUnit tests will run in parallel. This means there is no order and it doesn't make sense to be able to control that.

However, if tests aren't running in parallel, they can absolutely be ordered, and this is necessary for some systems.

To control ordering, there is an Order property on the [NotInParallelAttribute].

Orders will execute from smallest to largest. So 1 first, then 2, then 3, etc.

using TUnit.Core;

namespace MyTestProject;

public class MyTestClass
{
[Test]
[NotInParallel(Order = 1)]
public async Task MyTest()
{

}

[Test]
[NotInParallel(Order = 2)]
public async Task MyTest2()
{

}
}