How do I configure the concurrency level of XUnit through the the `dotnet test` CLI?

169 Views Asked by At

How do I configure the concurrency level of XUnit when run through the the dotnet test CLI ?

I've followed the advice from this thread: XUnit dotnet test parallel threads amount

and created a xunit.runner.json file that I believe ends up in the right location, and have specified the maxParallelThreads option found here, but my tests are still being run on the default number of threads.

What am I doing wrong? A minimum repo showing what I've done which doesn't work is here: https://github.com/keyboardDrummer/concurrencyTestingExperiment

The project contains tests that only pass when all 4 of them are run concurrently, but I can't get them to fail when running them using dotnet test.

1

There are 1 best solutions below

0
declan-bennie On

Your example is working properly -- I think maxParallelThreads just works differently than you're expecting it to.

Check out this GitHub issue thread, specifically this comment. I'm not sure what your goals are for concurrency in your tests, but there are some solutions shared there.

To see the maxParallelThreads

You can see your maxParallelThreads observed if you include diagnosticMessages set to true in your xunit.runner.json and run the tests with verbose console logging:

dotnet test --logger "console;verbosity=detailed"