Skip to content

Allow specifying the degree of parallelismΒ #4044

Closed as not planned
Closed as not planned
@MatisseHack

Description

@MatisseHack

Description

I have several test projects written with xUnit that I want to run in CI. These unit tests are IO bound and run much more quickly when parallelized with dotnet vstest --parallel. However, machines in my CI system (GitHub Actions) only have two CPU cores, which limits test execution to two concurrent assemblies. I would like to speed up my tests when run in CI by increasing the degree of parallelism further.

I added the following xunit.runner.json file to my project, but it only affected parallelization within each assembly.

{
  "parallelizeAssembly": true,
  "maxParallelThreads": -1
}

I was very surprised that parallelizeAssembly seemingly has no effect when run with the dotnet CLI. I assume MSBuild and VSTest create separate xUnit test runners for each assembly, which is why this setting has no effect?

I was able to work around that issue by using dotnet test --no-build -maxCpuCount:8, but the maxCpuCount parameter does not work with dotnet vstest, which tends to give me cleaner test output. Would it make sense to add support for maxCpuCount (or a similar parameter) in VSTest?

Steps to reproduce

Run dotnet vstest --parallel on a machine with more test projects than CPU cores.

Expected behavior

The dotnet CLI should respect properties in my xunit.runner.json file. However, barring that, it would be nice if there was a parameter that would increase the degree of parallelism when running dotnet vstest --parallel.

Actual behavior

A higher degree of parallelism can only be achieved when running tests through MSBuild (dotnet test).

Diagnostic logs

N/A

Environment

Linux and macOS

$ dotnet --version
6.0.401

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions