Skip to content

Improve output of dotnet test with MTP #49712

Closed

Description

@Youssef1313

When running individual test apps, we have output that show actively running tests. Related logic is around https://github.com/microsoft/testfx/blob/94360dfccacfc549d3a385300dba6ab40ca4736d/src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/AnsiTerminalTestProgressFrame.cs#L318

We should have similar experience in dotnet test.

Activity

  1. nohwnd commented on Jul 9, 2025

    @nohwnd
    Member

    Why this was not done is that we can easily have 12 processes writing the info to the screen (via the orchestrator) at the same time. So we need to balance the usability with performance. And see if it even is useful.

    I feel like I've written this in a detail somewhere, but I would see it as more useful to write a test that is slow / hanging, but don't write test that is fast. That way I can at least see useful info, instead of getting all updates.

    It would also help in ci, where we want to limit the number of updates written to the screen because they are all preserved.

  2. nohwnd commented on Jul 9, 2025

    @nohwnd
    Member

    described it here and here:

    microsoft/testfx#3728

    microsoft/testfx#3639

  3. Youssef1313 commented on Aug 6, 2025

    @Youssef1313
    MemberAuthor

    @nohwnd Do you want to close as "not planned" then? Or is there some balance we can find?

  4. nohwnd commented on Aug 7, 2025

    @nohwnd
    Member

    To me the solution is described in the second link, introduce a way to notify the progress bar about stuck tests or other interesting events. Rather than showing every single test.

  5. Evangelink commented on Aug 28, 2025

    @Evangelink
    Member

    I am not sure if I am saying the same thing as you did on your last comment @nohwnd but I believe that a quick win would be to do something similar to what is currently done in microsoft/testfx#4221 where we display tests on the available space and when we have more than what we can display we have the ... and X more.

  6. Evangelink commented on May 28, 2026

    @Evangelink
    Member

    A few findings after digging into the SDK side, plus thoughts on the trade-off @nohwnd raised.

    What's already in dotnet test

    The whole rendering machinery for "active tests + ... and X more" was actually ported from microsoft/testfx#4221 into the SDK and is sitting unused:

    What's missing to actually wire it up in the multi-process dotnet test flow:

    1. There's no IPC message for in-progress tests — the protocol only carries terminal results (TestResultMessages, TestStates has Passed/Skipped/Failed/Error/Timeout/Cancelled, no "started"/"running").
    2. TerminalTestReporter.TestInProgress is never called from TestApplicationHandler.OnTestResultsReceived.
    3. MicrosoftTestingPlatformTestCommand constructs TerminalTestReporterOptions without ShowActiveTests = true, and there's no user-facing flag.

    On the volume/cost concern

    I think we can address it without abandoning the "show running tests" UX, by combining two things:

    1. Producer-side threshold (MTP) — only emit the "in progress" event if a test has been running longer than e.g. 500ms-1s. Fast tests never generate any IPC traffic, so the 12-processes-screaming-at-the-orchestrator scenario disappears. This is essentially what Report interesting state in progress bar microsoft/testfx#3639 advocates: notify on interesting state, not on every test.
    2. Consumer-side budget (SDK) — the existing per-assembly fair share + "... and X more" handles vertical real estate, and we should additionally:
      • force ShowActiveTests=false when output is redirected / CI env-var is set, so CI logs aren't preserved with hundreds of progress updates,
      • cap per-assembly active rows independently of terminal height (e.g. max 2-3 per assembly) so 12 parallel modules don't each grab 5 rows on a tall terminal.

    That keeps the common case ("nothing slow") completely silent, while still answering the "is anything hung?" question that's the whole reason for this UX.

    Proposed plan for the SDK side

    # Change Where
    1 New IPC message TestInProgressMessage(s) carrying ExecutionId, InstanceId, Uid, DisplayName IPC/Models + IPC/Serializers + RegisterSerializers
    2 TestApplicationHandler.OnInProgressReceived → _output.TestInProgress(targetPath, tfm, arch, executionId, uid, displayName) TestApplicationHandler.cs + adjust TestInProgress signature to match TestCompleted
    3 --show-active-tests flag, defaulting to TTY-only TestCommandParser.cs, Options.cs, MicrosoftTestingPlatformTestCommand.cs
    4 CI/redirected-output guard in TerminalTestReporter TerminalTestReporter ctor

    A couple of small drive-by cleanups while in AnsiTerminalTestProgressFrame.cs:

    • the && false in the same-progress-item branch (line ~241) disables the "rewrite only the duration" fast path, which becomes noticeably worse for flicker once active tests are streamed,
    • could add a subtle highlight (e.g. DarkYellow) on entries past a long-running threshold so "the stuck one" is obvious without scanning timings.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions