2

How can I specify amount of threads while using dotnet test

Xunit 2.4.1 Xunit.runner.visualstudio 2.4.5 netcoreapp 3.1

The issue: I have a Job that is running tests using dotnet test and I have different agent with different performance capacity. For example One machine can handle 10 threads and the other only 6. Now the amount of threads specified in xunit.runner.json file. Could I specify amount of threads from the console? or can I specify the config file to use?

1 Answers1

0

According to the xUnit docs, you should reference xunit.runner.json within your csproj file like this:

<ItemGroup>
  <Content Include="xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

Doing so should pick up the config file in all cases (CLI, UI, etc.).

mu88
  • 4,156
  • 1
  • 23
  • 47
  • Yeap it's how I use it now, but can I have 2 different configs at the same time and specify which should be used before run started? – Kiril Runets Jun 14 '22 at 11:27
  • Yes, you can use the `Condition` attribute ({see here](https://learn.microsoft.com/en-us/visualstudio/msbuild/msbuild-conditions?view=vs-2022)) – mu88 Jun 14 '22 at 12:01