I am runnning all tests projects from solution level with a single command:
dotnet test
how can I make all tests projects(assemblies) run in parallel?
In Visual Studio there is a simple button "Run tests in parallel" which works perfectly but I need to use dotnet core test command for CI.
XUnit by default run all test tests in parallel which are sitting in separate class files. This makes it easy to run our test in parallel without us doing any special configuration.
Luckily, dotnet test using xUnit V2 runs the tests inside of a project (or even inside a solution) in parallel by default. So at least the tests inside of a project will be started in parallel.
Visual Studio 2019 runs unit tests sequentially when it is suppose to run them in parallel. Click on the Run Tests in Parallel button in Test Explorer. Make sure the icon is highlighted. Run unit tests.
There is currently no supported way to pass flags to dotnet test
. You must use configuration files instead.
xunit.runner.json:
{
"parallelizeAssembly": true
}
parallelizeAssembly
defaults to false
Set this to true if this assembly is willing to participate in parallelization with other assemblies. Test runners can use this information to automatically enable parallelization across assemblies if all the assemblies agree to it.
parallelizeTestCollections
defaults to true
Set this to true if the assembly is willing to run tests inside this assembly in parallel against each other. Tests in the same test collection will be run sequentially against each other, but tests in different test collections will be run in parallel against each other. Set this to false to disable all parallelization within this test assembly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With