Controlling the Serial and Parallel Test on XUnit
My Project requires both Serial and Parallel test execution on a project. I’d like to know how to handle this situation.
A collection is the unit of tests. The tests that are in the same collection, it runs serially. By default, it is per class.
If you want to run tests parallel, you need to split the class. In this case, ParallelTest01 and ParallelTest02 run parallelly. However, Test1() and Test2() run serially.
Run Serially for more than two classes
You can use
Collection annotation. It tells both classes are in the same collection. It runs as if it is in the same class. That means serial. In this case, Test7() and Test8() runs Serially.
Run Serially exclusively
However, in some use cases, we want to run parallel and serial in the same project. Even if you use
Collection , it runs parallelly as the different classes that mean Collections. I want to run almost all tests in parallel but for some test, it should run serially exclusively. You can use
DisableParallelization = true option with
CollectionDefinition Annotation. This option enables us that Parallel-capable test collections will be run first (in parallel), followed by parallel-disabled test collections (run sequentially).
SerialTest class will be executed after finishing any other tests.
For more information, you can refer to this page.
Running Tests in Parallel
Running unit tests in parallel is a new feature in xUnit.net version 2. There are two essential motivations that drove…