Added in NUnit 3.7
ParallelizableAttribute is used to indicate that a test and/or its descendants may be run in parallel with other tests. By default, no parallel execution takes place.
When used without an argument,
Parallelizable causes the test fixture or method on which it is placed to be queued for execution in parallel with other parallelizable tests. It may be used at the assembly, class or method level.
When tests are run in parallel, you are responsible for the thread safety of your tests. Tests that run at the same time and modify instance fields or properties without locks will cause unexpected behavior as they would in any multi-threaded program. If you are using fields or properties between parallel tests consider using the
FixtureLifeCycleAttribute to construct a new instance of a test fixture (class) for each test that is run.
The constructor takes an optional
ParallelScope enumeration argument (see below), which indicates whether the attribute applies to the item itself, to its descendants or both. It defaults to
ParallelScope.Self. The Scope may also be specified using the constructor argument
scope:, for example;
This is a [Flags] enumeration used to specify which tests may run in parallel. It applies to the test upon which it appears and any subordinate tests. The following values are available to users:
||the test itself may be run in parallel with other tests||Classes, Methods|
||child tests may be run in parallel with one another||Assembly, Classes|
||fixtures may be run in parallel with one another||Assembly, Classes|
||the test and its descendants may be run in parallel with others at the same level||Classes, Methods|
Some values are invalid on certain elements, although they will compile. NUnit will report any tests so marked as invalid and will produce an error message.
ParallelScopeenum has additional values, which are used internally but are not visible to users through Intellisense.
ParallelizableAttributemay be specified on multiple levels of the tests. Settings at a higher level may affect lower level tests, unless those lower-level tests override the inherited settings.