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
Summary
In server mode (
--server dotnettestcli --dotnet-test-pipe <pipe>),--list-tests jsonemits no JSON output. Both the buffering step and the emission step inTerminalOutputDeviceshort-circuit when_isServerModeis true.Background
microsoft/testfx#8280 added the
--list-tests jsonargument and JSON discovery output viaTerminalOutputDevice. 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 usingdotnet test --list-tests json.Where
src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/TerminalOutputDevice.cs:ConsumeAsync(around L534):_discoveredTestsForJsonis never populated when running under--server.DisplayAfterSessionEndRunAsync(around L419):The JSON document is never written when running under
--server.Repro
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
dotnet test --list-tests jsondotnet/sdk#49754 — request to expose--list-tests jsonfromdotnet test.dotnet test --list-tests jsonfor Microsoft.Testing.Platform dotnet/sdk#54490 — SDK CLI surface to forward--list-tests {text|json}(pending this fix to produce JSON output).