Skip to content

Re-print errored assemblies in dotnet test end-of-run recap#9545

Merged
Evangelink merged 2 commits into
mainfrom
dev/dotnet-test-errored-assembly-recap
Jul 2, 2026
Merged

Re-print errored assemblies in dotnet test end-of-run recap#9545
Evangelink merged 2 commits into
mainfrom
dev/dotnet-test-errored-assembly-recap

Conversation

@Evangelink

Copy link
Copy Markdown
Member

Summary

Follow-up to the handshake-failure visibility work for dotnet test (dotnet/sdk#51608), addressing the residual gap reported in dotnet/sdk#51952.

An assembly that does handshake but then exits with a non-zero code without any failed test — a crash, Environment.FailFast, a hang-dump kill, or an option rejected after the handshake (the original report was Unknown option '--hangdump') — currently only has its process output (exit code + stdout/stderr) printed inline by AssemblyRunCompleted. In a large multi-assembly dotnet test run that inline output is scrolled far above the summary and is extremely hard to find; only the one-line per-assembly result survives in the end-of-run summary, so you know which assembly errored but not why.

Handshake failures already get an end-of-run recap (Handshake failures: via AppendHandshakeFailureRecap); this PR gives errored-but-handshaked assemblies the same treatment.

Change

  • Record each assembly that exits non-zero with no failed test (assembly + tfm + arch + exit code + stdout + stderr) in TerminalTestReporter.ErroredAssemblies.cs.
  • Re-print them in a new Errored assemblies: section after the summary (AppendErroredAssemblyRecap), right after the handshake-failure recap.
  • Assemblies that exit non-zero because a test failed are intentionally excluded — those failures are already reported per-test, and re-dumping every failing assembly's output at the end would be noise. The recorded set mirrors the summary's existing error: N count (failedAssembliesWithoutFailedTests).
  • Reset the new state in TestExecutionCompleted alongside _handshakeFailures (HotReload correctness).
  • New ErroredAssembliesHeader resource string (+ xlf via UpdateXlf).

Orchestrator-only: the in-process host reaches neither the exit-code overload of AssemblyRunCompleted nor the recap, so its output is unchanged.

Tests

Added to TerminalTestReporterTests:

  • TestExecutionCompleted_WhenAssemblyErroredWithoutFailedTests_ReprintsErroredAssemblyRecap — asserts the recap header, the assembly identity, exit code, and captured stdout/stderr are surfaced at the end of the run.
  • TestExecutionCompleted_WhenAssemblyExitedNonZeroWithFailedTests_DoesNotReprintErroredAssemblyRecap — guards the scope (normal test failures are not recapped).

All 115 TerminalTestReporterTests pass locally (net9.0).

Fixes dotnet/sdk#51952

dotnet/sdk#51952: an assembly that handshakes but then exits non-zero without any failed test (crash, Environment.FailFast, a hang-dump kill, an option rejected after the handshake, ...) currently only prints its process output inline when it completes. In a large multi-assembly 'dotnet test' run that output is scrolled far above the summary and is very hard to find; only the one-line per-assembly result survives in the summary.

Mirror the existing handshake-failure recap: record each errored assembly (assembly + tfm + arch + exit code + stdout + stderr) and re-print it in an 'Errored assemblies:' section after the summary. Assemblies that exit non-zero because a test failed are excluded (already reported per-test); the recorded set mirrors the summary's 'error: N' count.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

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.

Pull request overview

Adds an end-of-run “Errored assemblies:” recap to the Terminal test reporter so that process-level failures (non-zero exit without failed tests) are discoverable in dotnet test multi-assembly runs, similar to the existing handshake-failure recap.

Changes:

  • Record assemblies that exit non-zero with FailedTests == 0 (including captured stdout/stderr) during AssemblyRunCompleted.
  • Append a new end-of-run recap section (“Errored assemblies:”) after the summary (and after the handshake-failure recap), and reset this state at TestExecutionCompleted for Hot Reload scenarios.
  • Add unit tests covering both inclusion (errored w/ no failed tests) and exclusion (non-zero exit due to failed tests), plus localized resource updates for the new header.
Show a summary per file
File Description
test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs Adds unit tests validating the new errored-assembly recap behavior and its intended scope.
src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/TerminalTestReporter.Summary.cs Appends the new errored-assembly recap after the existing handshake-failure recap.
src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/TerminalTestReporter.Lifecycle.cs Records eligible errored assemblies (non-zero exit, no failed tests) and clears recap state at end of execution.
src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/TerminalTestReporter.ErroredAssemblies.cs New implementation for tracking and rendering the “Errored assemblies:” recap.
src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/TerminalResources.resx Adds the new ErroredAssembliesHeader resource string.
src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/TerminalResources.cs Exposes TerminalResources.ErroredAssembliesHeader accessor.
src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/xlf/TerminalResources.cs.xlf Adds localized XLF entry for ErroredAssembliesHeader.
src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/xlf/TerminalResources.de.xlf Adds localized XLF entry for ErroredAssembliesHeader.
src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/xlf/TerminalResources.es.xlf Adds localized XLF entry for ErroredAssembliesHeader.
src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/xlf/TerminalResources.fr.xlf Adds localized XLF entry for ErroredAssembliesHeader.
src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/xlf/TerminalResources.it.xlf Adds localized XLF entry for ErroredAssembliesHeader.
src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/xlf/TerminalResources.ja.xlf Adds localized XLF entry for ErroredAssembliesHeader.
src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/xlf/TerminalResources.ko.xlf Adds localized XLF entry for ErroredAssembliesHeader.
src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/xlf/TerminalResources.pl.xlf Adds localized XLF entry for ErroredAssembliesHeader.
src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/xlf/TerminalResources.pt-BR.xlf Adds localized XLF entry for ErroredAssembliesHeader.
src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/xlf/TerminalResources.ru.xlf Adds localized XLF entry for ErroredAssembliesHeader.
src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/xlf/TerminalResources.tr.xlf Adds localized XLF entry for ErroredAssembliesHeader.
src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/xlf/TerminalResources.zh-Hans.xlf Adds localized XLF entry for ErroredAssembliesHeader.
src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/xlf/TerminalResources.zh-Hant.xlf Adds localized XLF entry for ErroredAssembliesHeader.

Review details

  • Files reviewed: 19/19 changed files
  • Comments generated: 0
  • Review effort level: Low

…test

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@Evangelink Evangelink enabled auto-merge (squash) July 2, 2026 18:22
@Evangelink Evangelink added the state/needs-review Awaiting review from the team. label Jul 2, 2026
@Evangelink Evangelink merged commit 4272d94 into main Jul 2, 2026
31 of 32 checks passed
@Evangelink Evangelink deleted the dev/dotnet-test-errored-assembly-recap branch July 2, 2026 18:31
github-actions Bot added a commit that referenced this pull request Jul 4, 2026
- Add --report-azdo-groups/--report-azdo-annotations toggles (#9542) to Platform changelog
- Add re-print errored assemblies in end-of-run recap (#9545) to Platform changelog
- Add server-initiated session cancellation (#9549) to Platform changelog
- Add fix for CloneWithUpdatedSource mutating this (#9581) to MSTest changelog

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Evangelink added a commit that referenced this pull request Jul 5, 2026
…9613)

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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.

dotnet test output can be hard to navigate

3 participants