"dotnet test": 如何运行 xunit 并行测试项目?

"dotnet test": how to run xunit tests projects in parallel?

我正在 运行使用单个命令从解决方案级别连接所有测试项目: dotnet test 如何让所有测试项目(程序集)运行 并行进行?

在 Visual Studio 中有一个简单的按钮 "Run tests in parallel",它工作得很好,但我需要为 CI 使用 dotnet core test 命令。

目前不支持将标志传递给 dotnet test 的方法。您必须改用 configuration files

xunit.runner.json:

{
    "parallelizeAssembly": true
}

parallelizeAssembly 默认为 false

Set this to true if this assembly is willing to participate in parallelization with other assemblies. Test runners can use this information to automatically enable parallelization across assemblies if all the assemblies agree to it.

parallelizeTestCollections 默认为 true

Set this to true if the assembly is willing to run tests inside this assembly in parallel against each other. Tests in the same test collection will be run sequentially against each other, but tests in different test collections will be run in parallel against each other. Set this to false to disable all parallelization within this test assembly.