"dotnet test": how to run xunit tests projects in parallel?

Deivydas Voroneckis picture Deivydas Voroneckis · Dec 28, 2018 · Viewed 15.1k times · Source

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.

Answer

rickvdbosch picture rickvdbosch · Dec 28, 2018

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.