Skip to content

Document dotnet test (MTP) argument forwarding caveat#54192

Merged
Evangelink merged 2 commits into
mainfrom
dev/amauryleve/dotnet-test-mtp-arg-forwarding
Jun 5, 2026
Merged

Document dotnet test (MTP) argument forwarding caveat#54192
Evangelink merged 2 commits into
mainfrom
dev/amauryleve/dotnet-test-mtp-arg-forwarding

Conversation

@Evangelink
Copy link
Copy Markdown
Member

@Evangelink Evangelink commented Jun 5, 2026

Documents the parser caveat from dotnet/sdk#51990 for dotnet test in Microsoft.Testing.Platform (MTP) mode.

When dotnet test consumes an option it recognizes (for example, --results-directory TestResults), the remaining tokens are forwarded to the test application. If a recognized option appears between an unrecognized option name and its value, removing the recognized option can change the meaning of the leftover arguments. For example:

dotnet test --report-trx --report-trx-filename --results-directory TestResults A.trx

becomes --report-trx --report-trx-filename A.trx for the test app, which then treats A.trx as the value of --report-trx-filename.

The same behavior exists in dotnet run and dotnet build (any unrecognized token is forwarded). The recommendation, as discussed in the issue, is to use a literal -- to mark where test application arguments begin so that dotnet test doesn't reorder or reinterpret them.

Changes

  • docs/core/tools/dotnet-test-mtp.md: adds a new Pass arguments to the test application section that explains the behavior, shows a concrete repro, and recommends using --.
  • docs/core/testing/unit-testing-with-dotnet-test.md: adds a tip in the Migrate to MTP mode section noting that even though -- is no longer required, it's still useful to avoid this parser quirk and future-proof scripts.

Internal previews

Closes dotnet/sdk#51990.


🤖 Generated with the assistance of GitHub Copilot CLI.


Internal previews

📄 File 🔗 Preview link
docs/core/testing/unit-testing-with-dotnet-test.md Testing with 'dotnet test'
docs/core/tools/dotnet-run.md dotnet run command
docs/core/tools/dotnet-test-mtp.md dotnet test with Microsoft.Testing.Platform (MTP)

When dotnet test consumes a recognized option that appears between an unrecognized option name and a value, the leftover tokens passed to the test application can change meaning. Document this behavior and recommend -- as a separator to mark test application arguments explicitly.

Addresses dotnet/sdk#51990.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Member

@Youssef1313 Youssef1313 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would document this in dotnet run instead, and link the dotnet run docs from dotnet test.

As is, this gives impression that it's MTP Test command problem.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR documents a dotnet test (Microsoft.Testing.Platform mode) argument-forwarding caveat where dotnet test consumes recognized options first, which can change how the remaining (forwarded) arguments bind to test-application options. It adds guidance to use a literal -- separator to prevent ambiguity and make scripts more resilient to future CLI option changes.

Changes:

  • Adds a new “Pass arguments to the test application” section to explain the forwarding behavior, provide a repro, and recommend --.
  • Adds a TIP in the MTP migration section to encourage continued use of -- for safer scripting, even though MTP mode no longer requires it.
Show a summary per file
File Description
docs/core/tools/dotnet-test-mtp.md Adds a new section documenting the forwarding caveat and recommending -- to avoid ambiguous argument binding.
docs/core/testing/unit-testing-with-dotnet-test.md Adds a TIP in the MTP migration guidance linking to the new caveat section and recommending -- for robustness.

Copilot's findings

  • Files reviewed: 2/2 changed files
  • Comments generated: 2

Comment thread docs/core/testing/unit-testing-with-dotnet-test.md Outdated
Comment thread docs/core/testing/unit-testing-with-dotnet-test.md Outdated
Address review feedback:

- @Youssef1313: move the detailed explanation of the parser caveat to `dotnet run` (where the behavior originates) and have `dotnet test` (MTP mode) link to it. This avoids giving the impression that the issue is specific to MTP.

- Copilot: split the TIP in unit-testing-with-dotnet-test.md into shorter sentences and remove the repeated `it`.

- Copilot: add `ai-usage: ai-assisted` to the unit-testing-with-dotnet-test.md frontmatter.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Evangelink
Copy link
Copy Markdown
Member Author

Good point — restructured in b245dd2 so the detailed explanation now lives in docs/core/tools/dotnet-run.md (new Forward arguments to the application section). dotnet test (MTP mode) keeps a short summary plus a link back to dotnet run to make clear the behavior is shared, not MTP-specific.

@Evangelink Evangelink enabled auto-merge (squash) June 5, 2026 12:42
Copy link
Copy Markdown
Member

@BillWagner BillWagner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM @Evangelink

I'll :shipit: now.

@Evangelink Evangelink merged commit 661b395 into main Jun 5, 2026
11 checks passed
@Evangelink Evangelink deleted the dev/amauryleve/dotnet-test-mtp-arg-forwarding branch June 5, 2026 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve dotnet test (MTP) parsing

4 participants