Currently, for our selenium UI tests, we are reading the available selenium server browsers to decide on the number of threads we will run our tests with and we pass the "workers" parameter when starting nunit console runner.
I am now migrating our automation to .net core. Unfortunately nunit console does not support .net core yet and we are now using "dotnet test" command to run the tests, which still runs the nunit tests.
I searched a lot, but could not find how to pass the "workers" parameter to nunit? There are other parameters for "dotnet test" for threads, but they do not allow you to run with more threads than there are cpu cores. Please note that I don't want to hardcode the number of threads in the assemblyInfo, since we often use different number of threads per our runs, depending on the selenium server against which the tests are run.
I tried using the .runsettings settings file when running the test command, but it seemed the parameter was not detected there too. What I end up with is a test run with threads equal to the number of cpu cores on the machine, but I need a lot more threads than that.
Versions:
According to https://github.com/nunit/docs/wiki/Tips-And-Tricks#NumberOfTestWorkers you can set number of workers using setting NumberOfTestWorkers.
You can do it in two ways: set it in .runsetting file and pass it with --settings option, or you can pass key-value pair right in a command line after "--" separator.
dotnet test Project.csproj -- NUnit.NumberOfTestWorkers=10
I tried using the .runsettings settings file when running the test command, but it seemed the parameter was not detected there too.
To get it working you just need to check that your project references NUnit3TestAdapter and that your .runsettings file has proper structure like this.
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<NUnit>
<NumberOfTestWorkers>10</NumberOfTestWorkers>
</NUnit>
</RunSettings>