Skip to content

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

@Evangelink

Description

@Evangelink

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)
{
    return Task.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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions