I am writing a script to build and test projects in a repository. For now I'm using the PowerShell command Get-ChildItem -Path test -Filter *.csproj -Recurse | ForEach-Object { dotnet test $_.FullName -c $Configuration }
to get all .csproj files in my test folder and run the tests in them. However, I notice when I run, for example, dotnet test test/ProjectA/ProjectA.csproj
I get this message:
A total of 1 test files matched the specified pattern.
Seeing this, I assumed it was possible to use a pattern to run tests in multiple projects with one command, but I can't find documentation for it or get it to work. When I try dotnet test test/**/*.csproj
I get:
MSBUILD : error MSB1009: Project file does not exist.
It doesn't seem to be currently supported. For now, the closest alternative is to pass solution file path to the dotnet test
command. That way, it will run all the tests from all the projects added to the solution.
dotnet test foo/bar.sln
Consider using dotnet test --filter FullyQualifiedName!~YourTestNameOrPartName
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With