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

14,886

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.

Share:
14,886

Related videos on Youtube

Deivydas Voroneckis
Author by

Deivydas Voroneckis

Software Engineer @ Atlantis Games

Updated on June 04, 2022

Comments

  • Deivydas Voroneckis
    Deivydas Voroneckis almost 2 years

    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.

  • Deivydas Voroneckis
    Deivydas Voroneckis over 5 years
    Thanks, I've been trying this way before but missed "Copy if newer option". Hope it will be the same efficient as "Run in parallel option" in Visual Studio. :)
  • dani herrera
    dani herrera about 5 years
    Try with: dotnet test -- xunit.parallelizeAssembly=true . Source github.com/Microsoft/vstest/issues/631
  • John Zabroski
    John Zabroski almost 5 years
    @daniherrera Is there any way I can easily see which tests have been loaded so far? I swear this is not working the way it's documented. I run the tests manually one by one, they pass. I run the tests all at once and they all fail. The tests are not thread-safe, so this makes sense. I'm using xunit theories.
  • Dmitry Pavlov
    Dmitry Pavlov almost 5 years
    Note, that if you are using fixtures test runner can't run tests in parallel (guess it's a bug), so you have to stick to single thread by setting "maxParallelThreads": -1 in your xunit.runner.json files or via passing corresponding command line command.
  • M.Hassan
    M.Hassan almost 4 years
    @daniherrera, there is no such a syntax for xunit, and only xunit.runner.json is supported, see ref from xunit author