diff --git a/src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/TerminalTestReporterCommandLineOptionsProvider.cs b/src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/TerminalTestReporterCommandLineOptionsProvider.cs
index 14052bec88a..7ae6c4c20fd 100644
--- a/src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/TerminalTestReporterCommandLineOptionsProvider.cs
+++ b/src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/TerminalTestReporterCommandLineOptionsProvider.cs
@@ -113,14 +113,15 @@ private static bool IsValidShowOutputArgument(string argument)
|| ShowOutputNoneArgument.Equals(argument, StringComparison.OrdinalIgnoreCase);
///
- /// Resolves --show-test-results, returning when the option is absent so the
- /// caller (TerminalOutputDevice.InitializeAsync) can fall back to its --output-based default.
+ /// Resolves --show-test-results or its passive configuration default, returning
+ /// when neither is present so the caller (TerminalOutputDevice.InitializeAsync) can fall back to its
+ /// --output-based default.
/// Arguments are already guaranteed valid by by the time a real run
/// reaches this method; an unexpected parse failure therefore indicates that command-line validation was
/// bypassed and is reported as an invalid application state.
///
internal static TestResultVisibility? GetShowTestResultsVisibility(ICommandLineOptions commandLineOptions)
- => !commandLineOptions.TryGetOptionArgumentList(ShowTestResultsOption, out string[]? arguments)
+ => !commandLineOptions.TryGetOptionArgumentListOrDefault(ShowTestResultsOption, out string[]? arguments)
? null
: TryParseShowTestResultsArguments(arguments ?? [], out TestResultVisibility visibility, out _)
? visibility
diff --git a/src/Platform/Microsoft.Testing.Platform/OutputDevice/TerminalOutputDevice.Initialization.cs b/src/Platform/Microsoft.Testing.Platform/OutputDevice/TerminalOutputDevice.Initialization.cs
index 6cdeee15d0b..a91ba265fc5 100644
--- a/src/Platform/Microsoft.Testing.Platform/OutputDevice/TerminalOutputDevice.Initialization.cs
+++ b/src/Platform/Microsoft.Testing.Platform/OutputDevice/TerminalOutputDevice.Initialization.cs
@@ -206,18 +206,17 @@ string s when TerminalTestReporterCommandLineOptionsProvider.ShowOutputNoneArgum
}
: isLLMEnvironment ? OutputShowMode.Failed : OutputShowMode.All;
- // Resolves which per-test terminal blocks are rendered. An explicit --show-test-results always wins over
- // --output, regardless of the order the two options appear on the command line (only --show-test-results is
- // consulted for the override, via TerminalTestReporterCommandLineOptionsProvider.GetShowTestResultsVisibility).
- // Absent --show-test-results, 'minimal' shows only failed results, 'detailed' shows every outcome, and
- // everything else (including no --output at all) shows failed and skipped results (passed tests stay hidden).
+ // Resolves which per-test terminal blocks are rendered. An explicit --show-test-results value or its passive
+ // configuration default wins over --output; an explicit value wins over the passive default. When neither is
+ // present, 'minimal' shows only failed results, 'detailed' shows every outcome, and everything else (including
+ // no --output at all) shows failed and skipped results (passed tests stay hidden).
// Internal for unit testing the parse seam that feeds
// TerminalTestReporterOptions.ShowTestResults.
internal static TestResultVisibility GetShowTestResultsVisibility(ICommandLineOptions commandLineOptions)
{
- if (TerminalTestReporterCommandLineOptionsProvider.GetShowTestResultsVisibility(commandLineOptions) is { } explicitVisibility)
+ if (TerminalTestReporterCommandLineOptionsProvider.GetShowTestResultsVisibility(commandLineOptions) is { } configuredVisibility)
{
- return explicitVisibility;
+ return configuredVisibility;
}
string? outputArgument = commandLineOptions.TryGetOptionArgumentList(TerminalTestReporterCommandLineOptionsProvider.OutputOption, out string[]? outputArguments)
diff --git a/test/Directory.Build.targets b/test/Directory.Build.targets
index 1c8c933235a..1ac8ce7fd2b 100644
--- a/test/Directory.Build.targets
+++ b/test/Directory.Build.targets
@@ -16,9 +16,6 @@
$(TestingPlatformCommandLineArguments) --crashdump
$(TestingPlatformCommandLineArguments) --hangdump --hangdump-timeout 15m
$(TestingPlatformCommandLineArguments) --report-azdo
-
- $(TestingPlatformCommandLineArguments) --show-test-results failed
$(TestingPlatformCommandLineArguments) --report-ctrf --report-ctrf-filename $(MSBuildProjectName)_$(TargetFramework).ctrf.json
+
+
+
diff --git a/test/UnitTests/Microsoft.Testing.Platform.UnitTests/Helpers/TestCommandLineOptions.cs b/test/UnitTests/Microsoft.Testing.Platform.UnitTests/Helpers/TestCommandLineOptions.cs
index f58fedb461e..f73357e9049 100644
--- a/test/UnitTests/Microsoft.Testing.Platform.UnitTests/Helpers/TestCommandLineOptions.cs
+++ b/test/UnitTests/Microsoft.Testing.Platform.UnitTests/Helpers/TestCommandLineOptions.cs
@@ -5,13 +5,26 @@
namespace Microsoft.Testing.Platform.UnitTests.Helpers;
-internal class TestCommandLineOptions : ICommandLineOptions
+internal class TestCommandLineOptions : ICommandLineOptions, ICommandLineOptionsWithDefaults
{
private readonly Dictionary _options;
+ private readonly Dictionary _defaults;
- public TestCommandLineOptions(Dictionary options) => _options = options;
+ public TestCommandLineOptions(Dictionary options)
+ : this(options, [])
+ {
+ }
+
+ public TestCommandLineOptions(Dictionary options, Dictionary defaults)
+ {
+ _options = options;
+ _defaults = defaults;
+ }
public bool IsOptionSet(string optionName) => _options.ContainsKey(optionName);
public bool TryGetOptionArgumentList(string optionName, [NotNullWhen(true)] out string[]? arguments) => _options.TryGetValue(optionName, out arguments);
+
+ bool ICommandLineOptionsWithDefaults.TryGetOptionArgumentListOrDefault(string optionName, [NotNullWhen(true)] out string[]? arguments)
+ => _options.TryGetValue(optionName, out arguments) || _defaults.TryGetValue(optionName, out arguments);
}
diff --git a/test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterCommandLineOptionsProviderTests.cs b/test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterCommandLineOptionsProviderTests.cs
index 7608139dd92..b6369de1f8c 100644
--- a/test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterCommandLineOptionsProviderTests.cs
+++ b/test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterCommandLineOptionsProviderTests.cs
@@ -425,6 +425,35 @@ public void GetShowTestResultsVisibility_WhenOptionPresent_ReturnsParsedFlags()
Assert.AreEqual(TestResultVisibility.Passed | TestResultVisibility.Skipped, TerminalTestReporterCommandLineOptionsProvider.GetShowTestResultsVisibility(options));
}
+ [TestMethod]
+ public void GetShowTestResultsVisibility_WhenPassiveDefaultPresent_ReturnsParsedFlags()
+ {
+ var options = new Helpers.TestCommandLineOptions(
+ [],
+ new Dictionary
+ {
+ [TerminalTestReporterCommandLineOptionsProvider.ShowTestResultsOption] = ["failed"],
+ });
+
+ Assert.AreEqual(TestResultVisibility.Failed, TerminalTestReporterCommandLineOptionsProvider.GetShowTestResultsVisibility(options));
+ }
+
+ [TestMethod]
+ public void GetShowTestResultsVisibility_WhenOptionAndPassiveDefaultPresent_OptionWins()
+ {
+ var options = new Helpers.TestCommandLineOptions(
+ new Dictionary
+ {
+ [TerminalTestReporterCommandLineOptionsProvider.ShowTestResultsOption] = ["skipped"],
+ },
+ new Dictionary
+ {
+ [TerminalTestReporterCommandLineOptionsProvider.ShowTestResultsOption] = ["failed"],
+ });
+
+ Assert.AreEqual(TestResultVisibility.Skipped, TerminalTestReporterCommandLineOptionsProvider.GetShowTestResultsVisibility(options));
+ }
+
[TestMethod]
public void GetShowTestResultsVisibility_WhenPresentValueWasNotValidated_Throws()
{
@@ -438,10 +467,10 @@ public void GetShowTestResultsVisibility_WhenPresentValueWasNotValidated_Throws(
Assert.AreEqual("The --show-test-results option was not validated.", exception.Message);
}
- // TerminalOutputDevice.GetShowTestResultsVisibility resolution/precedence: an explicit --show-test-results
- // always wins over --output; absent it, --output's 'Minimal' maps to 'failed', 'Detailed' maps to 'all', and
- // everything else (including no --output at all) maps to 'failed'+'skipped'. Since both options are read independently by name from the
- // same options bag, the resolution cannot depend on which one a user typed first on the command line.
+ // TerminalOutputDevice.GetShowTestResultsVisibility resolution/precedence: an explicit or passive-default
+ // --show-test-results value wins over --output; absent both, --output's 'Minimal' maps to 'failed', 'Detailed'
+ // maps to 'all', and everything else (including no --output at all) maps to 'failed'+'skipped'. Since both
+ // options are read independently by name from the same options bag, resolution cannot depend on CLI order.
//
// Comparisons cast to int: TerminalOutputDevice itself is not compiled into this test project (only the
// OutputDevice\Terminal folder is, via the Compile Include in the .csproj), so its return value is the