Xunit - disable parallelism in few tests of full set
If you have xunit >= 2.3 try [CollectionDefinition(DisableParallelization = true)].
It ability to disable cross-collection parallelization for individual test collections, via the test collection definition. Parallel-capable test collections will be run first (in parallel), followed by parallel-disabled test collections (run sequentially).
While Diver answer is correct it doesn't show how exactly to achieve this.
- Create new special class to establish test collection, something like this:
[CollectionDefinition(nameof(SystemTestCollectionDefinition), DisableParallelization = true)]public class SystemTestCollectionDefinition { }
- Now you can assign the same Collection name to all tests needed to disable parallelization. In my case I just added an attribute on the class which is base for all system tests:
[Collection(nameof(SystemTestCollectionDefinition))]public class BaseSystemTest { ... }
Now all tests within Collection will be executed in sequence.