6

I'm running a test solution with a build on a TFS server. I'm generating .trx files using the command

dotnet test --logger:trx;

on the whole solution, which includes multiple test projects. However, the default .trx files names don't contain an explicit reference to the test project they are linked to and I need that for automatic reporting purposes. They concatenate user, machine, date and time, that's it.

I know I can specify a full path and name in the command line with LogFileName={FullPath} but this is not dynamic since you have to specify the name and only works on a per project level not on the full solution (which makes sense since you can not use the same path and name for multiple test result files).

Is there any way to dynamically have the project name into the trx file via command line and/or on my TFS build definition (with the variables maybe) ? I did not find anything about that yet.

Thanks in advance !

Morgoth
  • 237
  • 2
  • 11

1 Answers1

1

One way this might be accomplished is to run the tests via a cake script.

foreach (var project in GetFiles($"../Tests/*/*.csproj"))
{
    var projectName = project.GetFilenameWithoutExtension();
    var dotNetTestSettings = new DotNetCoreTestSettings
    {
        Logger = $"trx;LogFileName={projectName}.trx",
        ResultsDirectory = "./TestResults",
    };
    DotNetCoreTest(project.FullPath, dotNetTestSettings);
}
piedar
  • 2,599
  • 1
  • 25
  • 37