Skip to content

Explain non-success MTP exit codes in test summaries - #10882

Merged
Amaury Levé (Evangelink) merged 3 commits into
mainfrom
dev/amauryleve/explain-exit-codes
Aug 31, 2026
Merged

Amaury Levé (Evangelink) merged 3 commits into
mainfrom
dev/amauryleve/explain-exit-codes

Conversation

@Evangelink

@Evangelink Amaury Levé (Evangelink) commented Aug 31, 2026 •

Copy link
Copy Markdown
Member

The dotnet test summary currently reports only a numeric MTP exit code and a documentation link, which makes common failures such as invalid command-line arguments unnecessarily opaque.

Changes

  • Add concise, localized descriptions for every known non-success MTP exit code.
  • Include the description in run and discovery summaries while preserving the exit-code documentation link.
  • Use an explicit fallback for unrecognized exit codes.
  • Keep the standalone terminal-reporter contract aligned and regenerate the XLIFF localization inputs.
  • Add acceptance coverage that compiles the shared reporter into an external consumer, executes it as a process, and verifies the final stdout line for run and discovery modes.

For example, exit code 5 is now reported as:

Test run completed with non-success exit code: 5. The command-line arguments are invalid. See: https://aka.ms/testingplatform/exitcodes

Validation

  • Built Microsoft.Testing.Platform.UnitTests for all target frameworks.
  • Built and ran Microsoft.Testing.Platform.TerminalReporterContract.UnitTests.
  • Ran all 183 TerminalTestReporterTests plus focused exit-code mapping tests.
  • Built Microsoft.Testing.Platform.Acceptance.IntegrationTests in Release and passed both external-process exit-code summary scenarios.

Downstream consideration

dotnet/sdk vendors this terminal reporter from testfx, so the SDK copy must be synchronized before the improved message appears in dotnet test.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings August 31, 2026 08:17
@Evangelink Amaury Levé (Evangelink) added the state/needs-review Awaiting review from the team. label Aug 31, 2026
@github-actions

This comment has been minimized.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Note

🤖 Automated review by GitHub Copilot. Generated by the Expert Code Review workflow. To request a follow-up action, reply by tagging @copilot directly.

Review Summary

Verdict: ✅ All clear — no blocking or major issues found.

# Dimension Verdict
1 Algorithmic Correctness ✅ All ExitCode enum values (1–15, skipping reserved 6) are covered in the switch; _ => Unknown handles future/unrecognized codes. Guard exitCode is null or (int)ExitCode.Success correctly short-circuits.
2 Threading & Concurrency N/A — new code is stateless (static methods, no shared mutable state).
3 Public API Surface ✅ No new public API added. GetExitCodeDescription is internal static.
4 Backward Compatibility ✅ Purely additive — new informational output appended after the existing summary line. No behavioral changes for success (exit code 0) or null.
5 Cross-TFM Correctness ✅ Uses only Enum.GetValues(typeof(ExitCode)) (available on all TFMs).
6 IPC Contract Stability N/A
7 Localization ✅ All 15 exit-code descriptions + 2 format strings added to .resx; xlf files regenerated across all 13 locales. URL correctly locked in comments.
8 Performance ✅ Negligible — a single switch on an int, executed once per test run completion.
9 Security N/A
10 Error Handling ✅ Unknown exit codes map to a generic "not recognized" description rather than throwing.
11 Resource Management N/A
12 Test Quality ✅ Two tests added: one validates a specific exit code renders the expected message; the other iterates every ExitCode enum value to ensure the switch is exhaustive — this will catch regressions if new exit codes are added without descriptions.
13 Code Style & Conventions ✅ Consistent with codebase style.
14 Documentation ✅ Output messages include `See: (aka.ms/redacted) link for discoverability.
15 MSBuild / Build ✅ TerminalReporterContract.props updated to include ExitCodes.cs in the contract surface — correctly keeps the SDK terminal reporter in sync.
16–22 Remaining dimensions N/A — no changes to nullable annotations, naming, init accessors, CLI options, analyzers, or PublicAPI.txt.

Clean, well-scoped PR. The exhaustive-enum test (GetExitCodeDescription_MapsEveryKnownFailureExitCode) is a nice guard against future regressions when new exit codes are added.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

Review tier: Balanced
Findings: 2 Medium severity · 2 Low severity

New issues introduced by this change (4)
Severity Finding
Medium severity src/​Platform/​Microsoft.Testing.Platform/​OutputDevice/​Terminal/​TerminalTestReporter.Lifecycle.cs — This new internal member is missing from InternalAPI/InternalAPI.Unshipped.txt, so the platform's…
Medium severity test/​UnitTests/​Microsoft.Testing.Platform.UnitTests/​OutputDevice/​Terminal/​TerminalTestReporterTests.cs — The new test covers only the run-summary resource, but the implementation also adds a separate…
Low severity test/​UnitTests/​Microsoft.Testing.Platform.TerminalReporterContract.UnitTests/​TerminalReporterContractTests.cs — This changed C# file is currently UTF-8 without a BOM, contrary to .editorconfig:66-67 (`charset…
Low severity src/​Platform/​Microsoft.Testing.Platform/​OutputDevice/​Terminal/​TerminalResources.cs — This changed C# file is currently UTF-8 without a BOM, contrary to .editorconfig:66-67 (`charset…
What changed in this PR

Improves MTP terminal summaries by explaining non-success exit codes, including the reporter contract vendored by dotnet/sdk.

Changes:

  • Maps known exit codes to localized descriptions with an unknown-code fallback.
  • Adds descriptions to run and discovery summaries.
  • Updates contract dependencies, localization inputs, and tests.
File Description
TerminalTestReporterTests.cs Tests exit-code rendering and mappings.
TerminalReporterContractTests.cs Validates the shared resource contract.
TerminalTestReporter.Lifecycle.cs Appends descriptive exit-code messages.
TerminalResources.resx Defines exit-code messages and descriptions.
TerminalResources.cs Adds strongly typed resource accessors.
TerminalReporterContract.props Adds the shared ExitCode dependency.
TerminalResources.cs.xlf Updates Czech localization inputs.
TerminalResources.de.xlf Updates German localization inputs.
TerminalResources.es.xlf Updates Spanish localization inputs.
TerminalResources.fr.xlf Updates French localization inputs.
TerminalResources.it.xlf Updates Italian localization inputs.
TerminalResources.ja.xlf Updates Japanese localization inputs.
TerminalResources.ko.xlf Updates Korean localization inputs.
TerminalResources.pl.xlf Updates Polish localization inputs.
TerminalResources.pt-BR.xlf Updates Brazilian Portuguese localization inputs.
TerminalResources.ru.xlf Updates Russian localization inputs.
TerminalResources.tr.xlf Updates Turkish localization inputs.
TerminalResources.zh-Hans.xlf Updates Simplified Chinese localization inputs.
TerminalResources.zh-Hant.xlf Updates Traditional Chinese localization inputs.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@Evangelink
Amaury Levé (Evangelink) enabled auto-merge (squash) August 31, 2026 08:41
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 31, 2026 09:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

Review tier: Balanced
Findings: 2 Medium severity · 2 Low severity

Pre-existing issues (4)
Severity Finding
Medium severity test/​UnitTests/​Microsoft.Testing.Platform.UnitTests/​OutputDevice/​Terminal/​TerminalTestReporterTests.cs — The new test covers only the run-summary resource, but the implementation also adds a separate… View comment
Medium severity src/​Platform/​Microsoft.Testing.Platform/​OutputDevice/​Terminal/​TerminalTestReporter.Lifecycle.cs — This new internal member is missing from InternalAPI/InternalAPI.Unshipped.txt, so the platform's… View comment
Low severity src/​Platform/​Microsoft.Testing.Platform/​OutputDevice/​Terminal/​TerminalResources.cs — This changed C# file is currently UTF-8 without a BOM, contrary to .editorconfig:66-67 (`charset… View comment
Low severity test/​UnitTests/​Microsoft.Testing.Platform.TerminalReporterContract.UnitTests/​TerminalReporterContractTests.cs — This changed C# file is currently UTF-8 without a BOM, contrary to .editorconfig:66-67 (`charset… View comment
Suppressed comments (2)

Previously missed (1) — in code that hasn't changed since the last review.

test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs:3239

  • This assertion does not verify that each exit code maps to its correct description; mapping every code to any non-unknown resource (or swapping two descriptions) still passes. Since this test is intended to cover every known mapping, assert the exact resource expected for each enum value.
            Assert.AreNotEqual(
                TerminalResources.ExitCodeUnknownDescription,
                TerminalTestReporter.GetExitCodeDescription((int)exitCode),
                $"Exit code '{exitCode}' should have a description.");

src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/TerminalTestReporter.Lifecycle.cs:204

  • This new internal member is part of the API-tracked Microsoft.Testing.Platform assembly, but it is absent from InternalAPI/InternalAPI.Unshipped.txt. Existing TerminalTestReporter internal members are tracked in InternalAPI.Shipped.txt:1744-1772, so RS0016 will fail the build. Add the generated signature for GetExitCodeDescription to the unshipped baseline (or make it private and update its tests).
    internal static string GetExitCodeDescription(int exitCode)

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 31, 2026 09:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

Review tier: Balanced
Findings: None

Issues resolved since last review (4)
Severity Finding
Low severity src/​Platform/​Microsoft.Testing.Platform/​OutputDevice/​Terminal/​TerminalResources.cs — This changed C# file is currently UTF-8 without a BOM, contrary to .editorconfig:66-67 (`charset… View resolved comment
Low severity test/​UnitTests/​Microsoft.Testing.Platform.TerminalReporterContract.UnitTests/​TerminalReporterContractTests.cs — This changed C# file is currently UTF-8 without a BOM, contrary to .editorconfig:66-67 (`charset… View resolved comment
Medium severity test/​UnitTests/​Microsoft.Testing.Platform.UnitTests/​OutputDevice/​Terminal/​TerminalTestReporterTests.cs — The new test covers only the run-summary resource, but the implementation also adds a separate… View resolved comment
Medium severity src/​Platform/​Microsoft.Testing.Platform/​OutputDevice/​Terminal/​TerminalTestReporter.Lifecycle.cs — This new internal member is missing from InternalAPI/InternalAPI.Unshipped.txt, so the platform's… View resolved comment
Suppressed comments (1)

Previously missed (1) — in code that hasn't changed since the last review.

test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs:3260

  • This assertion only proves that each enum value avoids the fallback; swapped or otherwise incorrect descriptions would all pass. Assert the exact resource expected for every exit code, while retaining a count check so adding a future enum member also requires a mapping test.
            Assert.AreNotEqual(
                TerminalResources.ExitCodeUnknownDescription,
                TerminalTestReporter.GetExitCodeDescription((int)exitCode),
                $"Exit code '{exitCode}' should have a description.");

@github-actions

Copy link
Copy Markdown
Contributor

🧵 Parallel-safety audit — PR #10882

Nothing audited here touches process-global state, shared filesystem paths, or [ResourceLock] / [DoNotParallelize] declarations. Nothing to flag for parallel-safety.

The PR adds/modifies three tests around MTP's TestExecutionCompleted exit-code reporting:

  • TerminalTestReporterTests.cs — new unit tests exercise TerminalTestReporter.GetExitCodeDescription (a pure switch expression, no static/shared state) and TestExecutionCompleted, writing only to a per-instance StringBuilderConsole.
  • TerminalReporterContractTests.cs — one new assertion reading a resource string constant (TerminalResources.TestRunExitCode); no I/O or environment mutation.
  • TerminalReporterExitCodeTests.cs (new, acceptance) — runs an isolated generated test asset via TestInfrastructure.TestHost, using only Environment.NewLine (read-only) and standard per-fixture asset generation (TestAssetFixtureBase); no shared/hardcoded paths or env-var mutation.

No changed [TestInitialize]/[ClassInitialize]/constructor/Dispose, no changed [ResourceLock]/[DoNotParallelize]/[Parallelize] declarations, and no parallelization-config changes (.runsettings, testconfig.json, Directory.Build.props) in this PR.

Audited Microsoft.Testing.Platform.UnitTests at scope MethodLevel, workers CPU count; Microsoft.Testing.Platform.TerminalReporterContract.UnitTests at scope MethodLevel, workers CPU count; Microsoft.Testing.Platform.Acceptance.IntegrationTests at scope MethodLevel, workers CPU count.

Re-run with /parallel-audit.

🤖 Automated content by GitHub Copilot. Generated by the Parallel-safety audit on PR (on open / sync) workflow. · auto · 74 AIC · ⌖ 3.57 AIC · ⊞ 24.8K · [◷]( · ◷)

@Evangelink
Amaury Levé (Evangelink) merged commit 3f2cf31 into main Aug 31, 2026
45 of 47 checks passed
@Evangelink
Amaury Levé (Evangelink) deleted the dev/amauryleve/explain-exit-codes branch August 31, 2026 11:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state/needs-review Awaiting review from the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants