Document dotnet test (MTP) argument forwarding caveat#54192
Conversation
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>
Youssef1313
left a comment
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
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>
|
Good point — restructured in b245dd2 so the detailed explanation now lives in docs/core/tools/dotnet-run.md (new |
BillWagner
left a comment
There was a problem hiding this comment.
This LGTM @Evangelink
I'll
now.
Documents the parser caveat from dotnet/sdk#51990 for dotnet test in Microsoft.Testing.Platform (MTP) mode.
When
dotnet testconsumes 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:becomes
--report-trx --report-trx-filename A.trxfor the test app, which then treatsA.trxas the value of--report-trx-filename.The same behavior exists in
dotnet runanddotnet 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 thatdotnet testdoesn't reorder or reinterpret them.Changes
docs/core/tools/dotnet-test-mtp.md: adds a newPass arguments to the test applicationsection 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