Search code examples
.nettestingautomated-testsxunitcsproj

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


I want to run all tests in several dotnet core C# test projects.

From the root folder if I run 'dotnet test /*.test.csproj' it will only run the tests one folder down. From the root folder if I run 'dotnet test **//*.test.csproj' it will only run the tests two folders down.

How can I get 'dotnet test' to recursively check all folders for a *.test.csproj project? i.e. run test from both projects above.


Solution

  • Run dotnet test without any argument in the root folder. Make sure you added a .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 with test files in folders:

    • Api.IntegrationTests\

    • Logic.Tests\

    • Subfolder\Another.Tests\

    I added the third test project just on my local computer (you will not see it on the GitHub repository) to make sure it works:

    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)