dotnet test running assemblies in parallel (when mixing core and framework test assemblies)
See original GitHub issueI have an issue where “dotnet test” is running assemblies in parallel. I have tried adding [NonParallelizable] and [assembly: LevelOfParallelism(1)] and also running with the dotnet test CLI option -p:ParallelizeTestCollections=false none of which has helped.
I have:
Solution \ MyLibrary.csproj (netstandard2.0) \ Tests461 (net461) \ TestsCore2 (netcoreapp2.2)
The nuget dependencies of both test csproj files are:
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
<PackageReference Include="NunitXml.TestLogger" Version="2.1.41" />
</ItemGroup>
When I run the tests using
dotnet test
I get the following logged:
Core SetUp 688503812
Core Enter Test 688503812
461 SetUp 688506609
461 Enter Test 688506609
Core Exit Test 688506812
461 Exit Test 688509625
It even looks like dotnet test is firing up 2 instances of the tester process (which don’t respect each other’s parallelization):
PS E:\MyLibrary> dotnet test
Test run for E:\MyLibrary\TestsCore2\bin\Debug\netcoreapp2.2\TestsCore2.dll(.NETCoreApp,Version=v2.2)
Microsoft (R) Test Execution Command Line Tool Version 16.3.0-preview-20190715-02
Copyright (c) Microsoft Corporation. All rights reserved.
Starting test execution, please wait...
Test run for E:\MyLibrary\Tests461\bin\Debug\net461\Tests461.dll(.NETFramework,Version=v4.6.1)
Microsoft (R) Test Execution Command Line Tool Version 16.3.0-preview-20190715-02
Copyright (c) Microsoft Corporation. All rights reserved.
Starting test execution, please wait...
Test Run Successful.
Total tests: 1
Passed: 1
Total time: 4.0100 Seconds
Test Run Successful.
Total tests: 1
Passed: 1
Total time: 4.0288 Seconds
PS E:\MyLibrary>
I have built a simple 3 project solution that reproduces the problem if it would help I can provide.
Other things I have tried:
dotnet test -- NUnit.NumberOfTestWorkers=1
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:10 (4 by maintainers)
Top Results From Across the Web
Run VSTest tests in parallel - Azure Pipelines
Typically, tests in an assembly are run in parallel. These test frameworks interface with the Visual Studio Test platform using a test ......
Read more >"dotnet test": how to run xunit tests projects in parallel?
Set this to true if the assembly is willing to run tests inside this assembly in parallel against each other. Tests in the...
Read more >Controlling the Serial and Parallel Test on XUnit
My Project requires both Serial and Parallel test execution on a project. I'd like to know how to handle this situation. A collection...
Read more >Visual Studio 2019 runs unit tests sequentially when it is ...
Steps to Reproduce. Click on the Run Tests in Parallel button in Test Explorer. Make sure the icon is highlighted. Run unit tests....
Read more >Running Tests in Parallel
Tests written in xUnit.net version 1 cannot be run in parallel against each other in the same assembly, though multiple test assemblies linked...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@tznind: See a workaround I posted here: https://github.com/dotnet/cli/issues/11017#issuecomment-564311592. I verified this works in your minimum repro:
For anyone still looking for a solution, there is the command line option
-m:1which specifies the maximum number of concurrent processes to use when building.Ref: