Skip to content

--list-tests json produces no JSON output when running in --server mode #8661

Description

Summary

In server mode (--server dotnettestcli --dotnet-test-pipe <pipe>), --list-tests json emits no JSON output. Both the buffering step and the emission step in TerminalOutputDevice short-circuit when _isServerMode is true.

Background

microsoft/testfx#8280 added the --list-tests json argument and JSON discovery output via TerminalOutputDevice. The .NET SDK (dotnet test) always launches MTP processes with --server dotnettestcli ... so the SDK can read handshake/discovery messages over a named pipe. As a result, the JSON output path is never triggered when using dotnet test --list-tests json.

Where

src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/TerminalOutputDevice.cs:

  • ConsumeAsync (around L534):
if(_isServerMode){returnTask.CompletedTask;}

_discoveredTestsForJson is never populated when running under --server.

  • DisplayAfterSessionEndRunAsync (around L419):
if(_isServerMode){return;}

The JSON document is never written when running under --server.

Repro

dotnet test --list-tests json

against any MTP test project: no JSON is emitted.

Suggested direction

Allow the JSON buffering + emission paths to run in server mode as well (gated on --list-tests json), or expose the JSON document over the dotnet-test-pipe protocol so the SDK can render it. Some care is needed to avoid double emission when both controller and test host roles run — today the JSON path is restricted to _processRole == TestProcessRole.TestHost (line ~442), which should continue to apply.

Related

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions