Search code examples
.nettesting.net-corexunitxunit2

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


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.


Solution

  • 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.