Show currently running tests in dotnet test MTP output (#49712)#54486
Merged
Conversation
Adds a new TestInProgressMessages IPC message type (serializer id 10) so that the test platform can notify the SDK when a test starts. The SDK already has rendering machinery for in-progress tests (TestProgressState, TestNodeResultsState, AnsiTerminalTestProgressFrame, including the '... and X more' trimming) but it was dead because the protocol carried no 'test started' event and ShowActiveTests was never enabled. Changes: * IPC layer: new TestInProgressMessages model + TLV serializer, registered with id 10. Back-compat is preserved by the TLV format (unknown field ids are skipped) and NamedPipeServer skipUnknownMessages, so old SDKs paired with new MTPs continue to work and vice-versa. * Handler: TestApplicationHandler.OnTestInProgressReceived forwards each event to TerminalTestReporter.TestInProgress(assembly, tfm, arch, executionId, instanceId, uid, displayName). * State: TestNodeResultsState now keys running tests by (instanceId, uid) and tracks a completed set, so a stale in-progress notification arriving after the matching test result cannot resurrect a 'running' entry. Retries (new instanceId) are still surfaced correctly. * Default-on: ShowActiveTests is enabled when AnsiMode == AnsiIfPossible and progress is not suppressed, so it stays off in CI, --no-ansi, --no-progress and LLM environments. * Tests: round-trip + serializer id assertion for the new serializer, plus stale-add suppression / retry handling for TestNodeResultsState. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR enables live display of currently running tests in dotnet test for Microsoft.Testing.Platform by adding an IPC message for in-progress tests and wiring it into the existing terminal progress renderer.
Changes:
- Adds
TestInProgressMessagesIPC model, serializer, field IDs, and serializer registration. - Dispatches in-progress test events through
TestApplicationHandlerintoTerminalTestReporter. - Updates active-test state tracking to key by
(instanceId, uid)and adds tests for serializer and state behavior.
Show a summary per file
| File | Description |
|---|---|
src/Cli/dotnet/Commands/Test/MTP/IPC/Models/TestInProgressMessages.cs |
Adds IPC records for running-test notifications. |
src/Cli/dotnet/Commands/Test/MTP/IPC/ObjectFieldIds.cs |
Reserves field and serializer IDs for in-progress test messages. |
src/Cli/dotnet/Commands/Test/MTP/IPC/Serializers/RegisterSerializers.cs |
Registers the new serializer. |
src/Cli/dotnet/Commands/Test/MTP/IPC/Serializers/TestInProgressMessagesSerializer.cs |
Implements TLV serialization for in-progress test messages. |
src/Cli/dotnet/Commands/Test/MTP/TestApplication.cs |
Routes the new message type to the handler. |
src/Cli/dotnet/Commands/Test/MTP/TestApplicationHandler.cs |
Validates and forwards running-test notifications to the reporter. |
src/Cli/dotnet/Commands/Test/MTP/Terminal/TerminalTestReporter.cs |
Adds instance-aware active-test updates and removal. |
src/Cli/dotnet/Commands/Test/MTP/Terminal/TestNodeResultsState.cs |
Tracks running tests by instance and suppresses stale completed entries. |
src/Cli/dotnet/Commands/Test/MTP/MicrosoftTestingPlatformTestCommand.cs |
Enables active-test display for ANSI progress mode. |
test/dotnet.Tests/CommandTests/Test/TestInProgressMessagesSerializerTests.cs |
Adds serializer round-trip and ID coverage. |
test/dotnet.Tests/CommandTests/Test/TestNodeResultsStateTests.cs |
Adds coverage for stale-add suppression and retry keying. |
Copilot's findings
- Files reviewed: 11/11 changed files
- Comments generated: 1
…pability The ShowActiveTests option is set based on the requested AnsiMode, but TerminalTestReporter may decide at runtime to disable progress (e.g. when stdout is redirected, console is non-TTY, or ANSI codes aren't accepted). In that case the incoming TestInProgress events would still allocate and update TestNodeResultsState even though nothing can ever be rendered. Compute an effective _showActiveTests in the ctor as _options.ShowActiveTests && showProgress and use it to gate both the AddRunningTestNode and RemoveRunningTestNode paths. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This was referenced May 29, 2026
JanKrivanek
approved these changes
Jun 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #49712.
What
Surfaces currently-running tests in the dotnet test output for projects using Microsoft.Testing.Platform (MTP). The SDK already has all of the rendering machinery for this (
TestProgressState/TestNodeResultsState/AnsiTerminalTestProgressFrame— including the... and X moretrimming), but it was dead code because:test startedevent for MTP, onlyTestResultMessages.TerminalTestReporterOptions.ShowActiveTestswas never set.This PR addresses both.
Changes
TestInProgressMessagesmodel + TLV serializer registered with id10. MirrorsDiscoveredTestMessages.TestApplication.OnRequestdispatches the new message;TestApplicationHandler.OnTestInProgressReceivedvalidates the execution id and forwards each item to the reporter.TerminalTestReporter.TestInProgressnow takes the same(assembly, tfm, arch, executionId, instanceId, uid, displayName)shape asTestCompleted.TestNodeResultsStatekeys running tests by(instanceId, uid)instead of justuid, and tracks acompletedset so a late in-progress notification can never resurrect a finished test. Retries (which get a newinstanceId) are surfaced correctly.ShowActiveTestsis enabled whenAnsiMode == AnsiIfPossibleand progress isn't suppressed (so it stays off in CI,--no-ansi,--no-progress, and LLM environments).Back-compat
The named-pipe protocol is not versioned for this change because TLV with unknown-id skip is sufficient:
NamedPipeServeris constructed withskipUnknownMessages: trueandTestApplication.OnRequestalready returnsVoidResponseforUnknownMessage, so the events are dropped silently.No protocol version bump is needed.
Producer-side gating (concern from @nohwnd)
@nohwnd flagged in #49712 that 12 parallel processes flooding
test startedevents for fast tests would be noisy. Mitigations in this PR:... and X moretrimming inTestNodeResultsState.GetRunningTasksalready handles bursty cases.The companion MTP-side PR is microsoft/testfx#8652, which actually emits the new
TestInProgressMessagesfromDotnetTestDataConsumeronInProgressTestNodeStateProperty. A further producer-side slow-test threshold (e.g. only emit after N ms) could be added there as a follow-up.Tests
TestInProgressMessagesSerializerTests— round-trip with populated and empty payloads; pins serializer id to10.TestNodeResultsStateTests— stale-add suppression after completion, retry path (newinstanceIdre-adds), distinct(instanceId, uid)keying.All 6 new tests pass.