Skip to content

Surface per-test standard output/error on the MTP execution path - #16284

Merged
Azat Mukhametshin (azat-msft) merged 1 commit into
microsoft:mainfrom
azat-msft:fix/mtp-stdout
Jul 14, 2026
Merged

Surface per-test standard output/error on the MTP execution path#16284
Azat Mukhametshin (azat-msft) merged 1 commit into
microsoft:mainfrom
azat-msft:fix/mtp-stdout

Conversation

@azat-msft

Copy link
Copy Markdown
Member

Problem

On the vstest.console path that runs a Microsoft.Testing.Platform (MTP) app as its own testhost (#16201), a test's standard output/error appeared in neither the console nor the TRX. Diagnostic output printed by tests was lost.

Root cause

The MTP test node does carry per-test standardOutput/standardError (confirmed from the raw JSON-RPC node), but MtpTestNodeConverter.ToTestResult never read them, so nothing was attached to the vstest TestResult for the loggers to write.

Fix

Map the node's standardOutput/standardError onto TestResult.Messages with the StandardOut/StandardError categories, matching the classic path where a test's captured output is attached to its result.

Test

New acceptance test RunMtpApplicationSurfacesPerTestStandardOutput: TestPassesToo now writes MTP_STDOUT_MARKER/MTP_STDERR_MARKER; the test runs the MTP app with /logger:trx and asserts both markers appear in the TRX.

Validation

  • RunMtpApplicationSurfacesPerTestStandardOutput: 2/2 matrix cases pass (markers absent on main).
  • Release build of Microsoft.TestPlatform.CrossPlatEngine and the acceptance project: clean.
  • Verified end-to-end against a real TUnit MTP app: the markers now appear in the TRX StdOut/StdErr.

The MTP test node carries per-test standardOutput/standardError, but
MtpTestNodeConverter.ToTestResult dropped them, so a test's captured output
appeared in neither the console nor the TRX. Map them onto the vstest result as
StandardOut/StandardError messages, matching the classic path.

Adds acceptance test RunMtpApplicationSurfacesPerTestStandardOutput; TestPassesToo
now writes markers that the test asserts reach the TRX.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: fb7de7a6-b8a1-4ebb-8266-5c5a948f245c
Copilot AI review requested due to automatic review settings July 14, 2026 10:32

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

This PR fixes missing per-test standard output/error when running Microsoft.Testing.Platform (MTP) applications via the vstest.console MTP execution path by mapping the MTP node’s standardOutput/standardError fields onto TestResult.Messages using the standard StandardOut/StandardError categories, enabling existing loggers (console/TRX) to surface the captured output.

Changes:

  • Add standardOutput / standardError protocol keys to MtpConstants.
  • Extend MtpTestNodeConverter.ToTestResult to attach per-test stdout/stderr as TestResultMessages.
  • Add an acceptance test that validates the markers appear in the generated TRX, and update the MTP MSTest asset to emit those markers.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
test/TestAssets/MtpMSTestProject/UnitTests.cs Emit stdout/stderr markers from a passing test to drive end-to-end validation.
test/Microsoft.TestPlatform.Acceptance.IntegrationTests/MtpUnderVstestTests.cs New acceptance test asserts stdout/stderr markers are present in the produced TRX.
src/Microsoft.TestPlatform.CrossPlatEngine/Client/MTP/MtpTestNodeConverter.cs Maps MTP per-test stdout/stderr fields onto TestResult.Messages for logger consumption.
src/Microsoft.TestPlatform.CrossPlatEngine/Client/MTP/MtpConstants.cs Adds constants for standardOutput/standardError node properties.

@azat-msft
Azat Mukhametshin (azat-msft) merged commit f48a80f into microsoft:main Jul 14, 2026
20 checks passed
Azat Mukhametshin (azat-msft) added a commit to azat-msft/vstest that referenced this pull request Jul 14, 2026
- RunMtpApplicationSurfacesPerTestStandardOutput asserted the old 4-test
  summary (2,1,1); the shared MtpMSTestProject asset gained a 5th test
  (RunSettingsEnvironmentVariableIsInjected), so the run is (3,1,1).
  This is a semantic collision between microsoft#16283 and microsoft#16284 that only
  surfaces when both are on main. Update the expected summary.
- Address review feedback: extract the near-identical MTP discovery
  routine from MtpProxyDiscoveryManager and MtpProxyExecutionManager into
  a single MtpClientHelpers.DiscoverSourceTests helper so the two paths
  cannot drift (timeouts, cancellation, sentinel drain, env-var policy).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 61d9a1c3-3c9f-4dab-8ba3-5baba8d55ed6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants