1

I am trying out the new-ish Microsoft.Testing.Platform in my C# unit tests. By default the platform does not produce TRX output, but there is an extension that allegedly provides TRX support: Microsoft.Testing.Extensions.TrxReport

I am referencing that NuGet, but when I try to set the TRX flag on the command line it rejects the flag:

PS C:\SRC\MstTrx> dotnet test --report-trx
MSBUILD : error MSB1001: Unknown switch.
    Full command line: 'C:\Program Files\dotnet\sdk\9.0.201\MSBuild.dll -maxcpucount -verbosity:m -tlp:default=auto -nologo -restore --property:VsTestUseMSBuildOutput=true -target:VSTest -nologo --report-trx -property:VSTestArtifactsProcessingMode=collect -property:VSTestSessionCorrelationId=26184_b9a78908-6fcd-4a57-a8f5-7121786eec3b -distributedlogger:Microsoft.DotNet.Tools.MSBuild.MSBuildLogger,C:\Program Files\dotnet\sdk\9.0.201\dotnet.dll*Microsoft.DotNet.Tools.MSBuild.MSBuildForwardingLogger,C:\Program Files\dotnet\sdk\9.0.201\dotnet.dll'
  Switches appended by response files:
Switch: --report-trx

For switch syntax, type "MSBuild -help"

It works fine if I just do dotnet test.

I have made a minimal failing example here: https://github.com/CAP-3Shape/MstTrx

The documentation of that TRX extension is very thin. Can anyone please tell me what I am missing?

Thanks!

2
  • 2
    What about if you do this: dotnet test -- --report-trx? Commented Apr 2 at 9:41
  • You are right! That helped. Commented Apr 4 at 14:03

1 Answer 1

3

There are two modes of dotnet test:

VSTest mode:

This is what's currently shipped, as VSTest has historically always been the only test platform in .NET, and dotnet test was designed specifically for VSTest. So dotnet test isn't aware of Microsoft.Testing.Platform (MTP) at all. To support MTP in the current dotnet test implementation:

  1. Microsoft.Testing.Platform.MSBuild NuGet package is required

  2. TestingPlatformDotnetTestSupport MSBuild property must be set to true.

  3. MTP-specific command-line options need to be specified after an extra --, as pointed out by @Martin Costello in comments. In VSTest world, anything after -- is forwarded to VSTest via MSBuild property called VSTestCLIRunSettings. When using Microsoft.Testing.Platform.MSBuild, we capture VSTestCLIRunSettings and treat it as "extra command-line arguments to test executable".

  4. Keep in mind that any VSTest-specific command-line options passed to dotnet test will be silently ignored.

MTP mode

This is a new mode of dotnet test that will be shipped in .NET 10 SDK.

It's available in latest .NET 10 SDK previews where you can opt-in via dotnet.config file:

[dotnet.test.runner]
name = "Microsoft.Testing.Platform"

IMPORTANT: In .NET 10 RC2, dotnet.config is removed, and the configuration is moved to global.json:

{
  "test": {
    "runner": "Microsoft.Testing.Platform"
  }
}

The new dotnet test mode is designed specifically for Microsoft.Testing.Platform, and doesn't require Microsoft.Testing.Platform.MSBuild NuGet package, nor requires TestingPlatformDotnetTestSupport MSBuild property.

You can read more about dotnet test in Testing with dotnet test article.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! The two dotnet.config files you posted are almost exactly identical. It took me a long time to figure out that they differ by one colon. Could you please leave a comment in your answer to point out the difference?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.