dotnet 测试不会使用通配符递归搜索 .csproj 的文件夹

dotnet test doesn't recursively search folders for .csproj with wildcards

我想 运行 几个 dotnet 核心 C# 测试项目中的所有测试。

如果我 运行 'dotnet test /*.test.csproj' 从根文件夹,它只会 运行 测试一个文件夹。 如果我 运行 'dotnet test **//*.test.csproj' 从根文件夹,它只会 运行 测试两个文件夹。

如何让 'dotnet test' 递归检查 *.test.csproj 项目的所有文件夹?即 运行 以上两个项目的测试。

运行 dotnet test 根文件夹中没有任何参数。确保您在文件夹中添加了 .sln file that defines the path for all the projects of your solution, including the test projects. It works for my GitHub repository for an API 和测试文件:

  • Api.IntegrationTests\

  • Logic.Tests\

  • Subfolder\Another.Tests\

我在我的本地计算机上添加了第三个测试项目(您不会在 GitHub 存储库中看到它)以确保它有效:

Test run for ...\Subfolder\Another.Tests\bin\Debug\netcoreapp3.0\Another.Tests.dll(.NETCoreApp,Version=v3.0)

Test run for ...\Logic.Tests\bin\Debug\netcoreapp3.0\Logic.Tests.dll(.NETCoreApp,Version=v3.0)

Test run for ...\Api.IntegrationTests\bin\Debug\netcoreapp3.0\Api.IntegrationTests.dll(.NETCoreApp,Version=v3.0)