Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dotnet test command logger only writes outputs of the last test when solution with multiple projects is specified to be tested

While trying to automate my MSTest based tests using dotnet test command I am experiencing an issue where only the outputs of the last test project run (in the solution) are written to the specified logger output

I have tried running the command line is as follows :

dotnet test $ProjectSln --results-directory ./Reports -l "trx;LogFileName=$($ReportFile)" "/p:GeneratePackageOnBuild=False;Configuration=Release;Platform=Any CPU;SolutionDir=${RootDir}"# "-verbosity:minimal"

but that produces an xml file containing only outputs of a single project tests.

Is there any way to make the command log outputs of all tests to a single file?

like image 807
ismar agilent Avatar asked Sep 19 '25 08:09

ismar agilent


1 Answers

Since the command executes tests in multiple projects, use the LogFilePrefix argument instead of LogFileName:

dotnet test $ProjectSln --results-directory ./Reports -l "trx;LogFilePrefix=$($ReportFile)" "/p:GeneratePackageOnBuild=False;Configuration=Release;Platform=Any CPU;SolutionDir=${RootDir}"
#                                                             ^^^^^^^^^^^^^

Here is the same command formatted on multiple lines if that is easier to read:

dotnet test $ProjectSln `
            --results-directory ./Reports `
            -l "trx;LogFilePrefix=$($ReportFile)" `
            "/p:GeneratePackageOnBuild=False;Configuration=Release;Platform=Any CPU;SolutionDir=${RootDir}"

The Microsoft documentation has a number of examples you can reference.

like image 134
Greg Burghardt Avatar answered Sep 21 '25 04:09

Greg Burghardt