Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Test multiple projects with dotnet test using pattern

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.

like image 225
Valuator Avatar asked Nov 19 '19 19:11

Valuator


2 Answers

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

like image 55
Sateesh Pagolu Avatar answered Sep 20 '22 18:09

Sateesh Pagolu


Consider using dotnet test --filter FullyQualifiedName!~YourTestNameOrPartName

like image 44
Riddik Avatar answered Sep 18 '22 18:09

Riddik