question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

dotnet test seems to ignore runsettings MaxCpuCount

See original GitHub issue

Description

dotnet test when run against a solution that contains multiple test projects, appears to spin up a parallel test runner for each test project.

Attempting to limit to one test runner at a time via the MaxCpuCount value in a .runsettings file doesn’t work.

Steps to reproduce

  1. Create a solution with two or more test projects that use NUnit
  2. Create a .runsettings file that sets MaxCpuCount=1
  3. run dotnet test --settings pathtofile.runsettings

Expected behavior

Tests assemblies are run sequentially

Actual behavior

Test assemblies are run in parallel (seen in my case where the tests are database tests and they end up fighting for access to the database)

Diagnostic logs

Environment

Windows 10 1809, vstest.console 15.0.28307.421 .NET Core SDK 2.2.200/2.2.202

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
smchan514commented, Jan 29, 2022

For anyone still looking for a solution, there is the command line option -m:1 which specifies the maximum number of concurrent processes to use when building.

dotnet test -m:1 MyUnitTests.sln

Ref:

  1. https://github.com/dotnet/sdk/issues/10178
  2. MSBuild command-line reference – Switches
2reactions
Mpdreamzcommented, Dec 18, 2019

Even the fact that console loggers will be intermixed makes me want to run sequentially on CI to get sane output. MaxCpuCount is not a fix.

Please reconsider reopening this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configure unit tests by using a .runsettings file
runsettings file. Select test settings file menu in Visual Studio 2019. The file appears on the Test menu, and you can select or...
Read more >
runsettings test file values not being applied
I faced the same issue. For coded UI Tests please use timeout attribute in test method [Timeout(milliseconds)] public void DemoTest() { }.
Read more >
"dotnet test -- RunSettings" doesn't pass settings to test
Create a new .Net Core MSTest Test Project. Set the test class to this: [TestClass] public class UnitTest1 { public TestContext TestContext { ......
Read more >
Test Configuration with .NET Core and NUnit 3
Setting configuration using .runsettings files ... Select Test > Test Settings > Select Test Settings File and then select the .runsettings file.
Read more >
Code coverage in .NET 5 with MSTest - Bart Simons
I only want my own application to be tested and with a runsettings file you can fix this. It supports regular expressions and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found