1

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?

Greg Burghardt
  • 17,900
  • 9
  • 49
  • 92

1 Answers1

1

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.

Greg Burghardt
  • 17,900
  • 9
  • 49
  • 92
  • 1
    Thanks Greg, this is significant an improvement as it allows me to have a log file per test project. It would be even better if I could use test project names as a prefix to each log file , but it does not look like it is possible ? – ismar agilent May 03 '23 at 23:20