From 8b48bbc6c9396fe8afd8e076c587d458aa152bfa Mon Sep 17 00:00:00 2001 From: Youssef1313 Date: Tue, 24 Mar 2026 13:13:22 +0100 Subject: [PATCH 1/4] Avoid printing stdout/stderr properties in console --- .../Terminal/TerminalTestReporter.cs | 40 +++---------------- .../OutputDevice/TerminalOutputDevice.cs | 26 +++--------- .../Resources/PlatformResources.resx | 6 --- .../Resources/xlf/PlatformResources.cs.xlf | 10 ----- .../Resources/xlf/PlatformResources.de.xlf | 10 ----- .../Resources/xlf/PlatformResources.es.xlf | 10 ----- .../Resources/xlf/PlatformResources.fr.xlf | 10 ----- .../Resources/xlf/PlatformResources.it.xlf | 10 ----- .../Resources/xlf/PlatformResources.ja.xlf | 10 ----- .../Resources/xlf/PlatformResources.ko.xlf | 10 ----- .../Resources/xlf/PlatformResources.pl.xlf | 10 ----- .../Resources/xlf/PlatformResources.pt-BR.xlf | 10 ----- .../Resources/xlf/PlatformResources.ru.xlf | 10 ----- .../Resources/xlf/PlatformResources.tr.xlf | 10 ----- .../xlf/PlatformResources.zh-Hans.xlf | 10 ----- .../xlf/PlatformResources.zh-Hant.xlf | 10 ----- 16 files changed, 11 insertions(+), 191 deletions(-) diff --git a/src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/TerminalTestReporter.cs b/src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/TerminalTestReporter.cs index 27068be482..232351c3af 100644 --- a/src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/TerminalTestReporter.cs +++ b/src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/TerminalTestReporter.cs @@ -332,9 +332,7 @@ internal void TestCompleted( string? errorMessage, Exception? exception, string? expected, - string? actual, - string? standardOutput, - string? errorOutput) + string? actual) { FlatException[] flatExceptions = ExceptionFlattener.Flatten(errorMessage, exception); TestCompleted( @@ -345,9 +343,7 @@ internal void TestCompleted( informativeMessage, flatExceptions, expected, - actual, - standardOutput, - errorOutput); + actual); } private void TestCompleted( @@ -358,9 +354,7 @@ private void TestCompleted( string? informativeMessage, FlatException[] exceptions, string? expected, - string? actual, - string? standardOutput, - string? errorOutput) + string? actual) { if (_testProgressState is null) { @@ -404,9 +398,7 @@ private void TestCompleted( informativeMessage, exceptions, expected, - actual, - standardOutput, - errorOutput)); + actual)); } } @@ -424,9 +416,7 @@ private void RenderTestCompleted( string? informativeMessage, FlatException[] flatExceptions, string? expected, - string? actual, - string? standardOutput, - string? errorOutput) + string? actual) { if (outcome == TestOutcome.Passed && !GetShowPassedTests()) { @@ -468,7 +458,6 @@ private void RenderTestCompleted( FormatExpectedAndActual(terminal, expected, actual); FormatStackTrace(terminal, flatExceptions, 0); FormatInnerExceptions(terminal, flatExceptions); - FormatStandardAndErrorOutput(terminal, standardOutput, errorOutput); } private static void FormatInnerExceptions(ITerminal terminal, FlatException[] exceptions) @@ -556,25 +545,6 @@ private static void FormatStackTrace(ITerminal terminal, FlatException[] excepti terminal.ResetColor(); } - private static void FormatStandardAndErrorOutput(ITerminal terminal, string? standardOutput, string? standardError) - { - if (RoslynString.IsNullOrWhiteSpace(standardOutput) && RoslynString.IsNullOrWhiteSpace(standardError)) - { - return; - } - - terminal.SetColor(TerminalColor.DarkGray); - terminal.Append(SingleIndentation); - terminal.AppendLine(PlatformResources.StandardOutput); - string? standardOutputWithoutSpecialChars = MakeControlCharactersVisible(standardOutput, normalizeWhitespaceCharacters: false); - AppendIndentedLine(terminal, standardOutputWithoutSpecialChars, DoubleIndentation); - terminal.Append(SingleIndentation); - terminal.AppendLine(PlatformResources.StandardError); - string? standardErrorWithoutSpecialChars = MakeControlCharactersVisible(standardError, normalizeWhitespaceCharacters: false); - AppendIndentedLine(terminal, standardErrorWithoutSpecialChars, DoubleIndentation); - terminal.ResetColor(); - } - private void AppendAssemblyLinkTargetFrameworkAndArchitecture(ITerminal terminal) { terminal.AppendLink(_assembly, lineNumber: null); diff --git a/src/Platform/Microsoft.Testing.Platform/OutputDevice/TerminalOutputDevice.cs b/src/Platform/Microsoft.Testing.Platform/OutputDevice/TerminalOutputDevice.cs index 86cd4d5de7..a0984459c3 100644 --- a/src/Platform/Microsoft.Testing.Platform/OutputDevice/TerminalOutputDevice.cs +++ b/src/Platform/Microsoft.Testing.Platform/OutputDevice/TerminalOutputDevice.cs @@ -391,8 +391,6 @@ public Task ConsumeAsync(IDataProducer dataProducer, IData value, CancellationTo case TestNodeUpdateMessage testNodeStateChanged: TimeSpan? duration = testNodeStateChanged.TestNode.Properties.SingleOrDefault()?.GlobalTiming.Duration; - string? standardOutput = testNodeStateChanged.TestNode.Properties.SingleOrDefault()?.StandardOutput; - string? standardError = testNodeStateChanged.TestNode.Properties.SingleOrDefault()?.StandardError; foreach (FileArtifactProperty artifact in testNodeStateChanged.TestNode.Properties.OfType()) { @@ -420,9 +418,7 @@ public Task ConsumeAsync(IDataProducer dataProducer, IData value, CancellationTo errorState.Explanation, errorState.Exception, expected: null, - actual: null, - standardOutput, - standardError); + actual: null); break; case FailedTestNodeStateProperty failedState: @@ -435,9 +431,7 @@ public Task ConsumeAsync(IDataProducer dataProducer, IData value, CancellationTo failedState.Explanation, failedState.Exception, expected: failedState.Exception?.Data["assert.expected"] as string, - actual: failedState.Exception?.Data["assert.actual"] as string, - standardOutput, - standardError); + actual: failedState.Exception?.Data["assert.actual"] as string); break; case TimeoutTestNodeStateProperty timeoutState: @@ -450,9 +444,7 @@ public Task ConsumeAsync(IDataProducer dataProducer, IData value, CancellationTo timeoutState.Explanation, timeoutState.Exception, expected: null, - actual: null, - standardOutput, - standardError); + actual: null); break; #pragma warning disable CS0618 // Type or member is obsolete @@ -467,9 +459,7 @@ public Task ConsumeAsync(IDataProducer dataProducer, IData value, CancellationTo cancelledState.Explanation, cancelledState.Exception, expected: null, - actual: null, - standardOutput, - standardError); + actual: null); break; case PassedTestNodeStateProperty: @@ -482,9 +472,7 @@ public Task ConsumeAsync(IDataProducer dataProducer, IData value, CancellationTo errorMessage: null, exception: null, expected: null, - actual: null, - standardOutput, - standardError); + actual: null); break; case SkippedTestNodeStateProperty skippedState: @@ -497,9 +485,7 @@ public Task ConsumeAsync(IDataProducer dataProducer, IData value, CancellationTo errorMessage: null, exception: null, expected: null, - actual: null, - standardOutput, - standardError); + actual: null); break; case DiscoveredTestNodeStateProperty: diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/PlatformResources.resx b/src/Platform/Microsoft.Testing.Platform/Resources/PlatformResources.resx index 2cc2dc1ba7..6f3637fe6b 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/PlatformResources.resx +++ b/src/Platform/Microsoft.Testing.Platform/Resources/PlatformResources.resx @@ -625,12 +625,6 @@ Takes one argument as string in the format <value>[h|m|s] where 'value' is Expected --client-port when jsonRpc protocol is used. - - Error output - - - Standard output - Discovering tests from diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.cs.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.cs.xlf index 5c7b467e23..2b924dedec 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.cs.xlf +++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.cs.xlf @@ -743,16 +743,6 @@ Může mít jenom jeden argument jako řetězec ve formátu <value>[h|m|s] Trasování zásobníku - - Error output - Chybový výstup - - - - Standard output - Standardní výstup - - Starting test session. Spouští se testovací relace. diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.de.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.de.xlf index 785ae9424f..ce8e09d268 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.de.xlf +++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.de.xlf @@ -743,16 +743,6 @@ Nimmt ein Argument als Zeichenfolge im Format <value>[h|m|s], wobei "value Stapelüberwachung - - Error output - Fehlerausgabe - - - - Standard output - Standardausgabe - - Starting test session. Die Testsitzung wird gestartet. diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.es.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.es.xlf index b7c2f188b5..fe210c069c 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.es.xlf +++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.es.xlf @@ -743,16 +743,6 @@ Toma un argumento como cadena con el formato <value>[h|m|s] donde 'value' Seguimiento de la pila - - Error output - Salida de error - - - - Standard output - Salida estándar - - Starting test session. Iniciando sesión de prueba. diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.fr.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.fr.xlf index ead8ec347e..a751efeeaa 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.fr.xlf +++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.fr.xlf @@ -743,16 +743,6 @@ Prend un argument sous forme de chaîne au format <value>[h|m|s] où « v Rapport des appels de procédure - - Error output - Sortie d’erreur - - - - Standard output - Sortie standard - - Starting test session. Démarrage de la session de test. diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.it.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.it.xlf index 259624f713..affb9fdab4 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.it.xlf +++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.it.xlf @@ -743,16 +743,6 @@ Acquisisce un argomento come stringa nel formato <value>[h|m|s] dove 'valu Analisi dello stack - - Error output - Output errori - - - - Standard output - Output standard - - Starting test session. Avvio della sessione di test. diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ja.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ja.xlf index 9f7fee7d9b..ad63d8d404 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ja.xlf +++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ja.xlf @@ -744,16 +744,6 @@ Takes one argument as string in the format <value>[h|m|s] where 'value' is スタック トレース - - Error output - エラー出力 - - - - Standard output - 標準出力 - - Starting test session. テスト セッションを開始しています。 diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ko.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ko.xlf index 0f846ecee3..223c23822f 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ko.xlf +++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ko.xlf @@ -743,16 +743,6 @@ Takes one argument as string in the format <value>[h|m|s] where 'value' is 스택 추적 - - Error output - 오류 출력 - - - - Standard output - 표준 출력 - - Starting test session. 테스트 세션을 시작하는 중입니다. diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.pl.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.pl.xlf index e0ccb7806a..e1ea46816d 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.pl.xlf +++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.pl.xlf @@ -743,16 +743,6 @@ Pobiera jeden argument jako ciąg w formacie <value>[h|m|s], gdzie element Śledzenie stosu - - Error output - Dane wyjściowe w przypadku błędu - - - - Standard output - Standardowe dane wyjściowe - - Starting test session. Rozpoczynanie sesji testowej. diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.pt-BR.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.pt-BR.xlf index 0bdff4258c..7b73e59a16 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.pt-BR.xlf +++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.pt-BR.xlf @@ -743,16 +743,6 @@ Recebe um argumento como cadeia de caracteres no formato <valor>[h|m|s] em Rastreamento de Pilha - - Error output - Saída de erros - - - - Standard output - Saída padrão - - Starting test session. Iniciando sessão de teste. diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ru.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ru.xlf index 20b010b0b1..b1234a8cc5 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ru.xlf +++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ru.xlf @@ -743,16 +743,6 @@ Takes one argument as string in the format <value>[h|m|s] where 'value' is Трассировка стека - - Error output - Вывод ошибок - - - - Standard output - Стандартный вывод - - Starting test session. Запуск тестового сеанса. diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.tr.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.tr.xlf index 077a900c3b..d84944175e 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.tr.xlf +++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.tr.xlf @@ -743,16 +743,6 @@ Bir bağımsız değişkeni, 'value' değerinin kayan olduğu <value>[h|m| Yığın İzlemesi - - Error output - Hata çıkışı - - - - Standard output - Standart çıkış - - Starting test session. Test oturumu başlatılıyor. diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.zh-Hans.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.zh-Hans.xlf index f5f6f74d28..a770808d02 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.zh-Hans.xlf +++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.zh-Hans.xlf @@ -743,16 +743,6 @@ Takes one argument as string in the format <value>[h|m|s] where 'value' is 堆栈跟踪 - - Error output - 错误输出 - - - - Standard output - 标准输出 - - Starting test session. 正在启动测试会话。 diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.zh-Hant.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.zh-Hant.xlf index 2be95182cf..a8968ac99e 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.zh-Hant.xlf +++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.zh-Hant.xlf @@ -743,16 +743,6 @@ Takes one argument as string in the format <value>[h|m|s] where 'value' is 堆疊追蹤 - - Error output - 錯誤輸出 - - - - Standard output - 標準輸出 - - Starting test session. 正在啟動測試會話。 From 64a1e14996fc6cb79d44b7156f44ba9385003cc7 Mon Sep 17 00:00:00 2001 From: Youssef Victor Date: Tue, 24 Mar 2026 13:31:58 +0100 Subject: [PATCH 2/4] Update TerminalTestReporterTests.cs --- .../Terminal/TerminalTestReporterTests.cs | 138 ++++-------------- 1 file changed, 31 insertions(+), 107 deletions(-) diff --git a/test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs b/test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs index f3081c81dd..e1f5b120f7 100644 --- a/test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs +++ b/test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs @@ -121,20 +121,18 @@ public void NonAnsiTerminal_OutputFormattingIsCorrect() string folder = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? @"C:\work\" : "/mnt/work/"; terminalReporter.AssemblyRunStarted(); - string standardOutput = "Hello!"; - string errorOutput = "Oh no!"; terminalReporter.TestCompleted(testNodeUid: "PassedTest1", "PassedTest1", TestOutcome.Passed, TimeSpan.FromSeconds(10), - informativeMessage: null, errorMessage: null, exception: null, expected: null, actual: null, standardOutput, errorOutput); + informativeMessage: null, errorMessage: null, exception: null, expected: null, actual: null); terminalReporter.TestCompleted(testNodeUid: "SkippedTest1", "SkippedTest1", TestOutcome.Skipped, TimeSpan.FromSeconds(10), - informativeMessage: null, errorMessage: null, exception: null, expected: null, actual: null, standardOutput, errorOutput); + informativeMessage: null, errorMessage: null, exception: null, expected: null, actual: null); // timed out + canceled + failed should all report as failed in summary terminalReporter.TestCompleted(testNodeUid: "TimedoutTest1", "TimedoutTest1", TestOutcome.Timeout, TimeSpan.FromSeconds(10), - informativeMessage: null, errorMessage: null, exception: null, expected: null, actual: null, standardOutput, errorOutput); + informativeMessage: null, errorMessage: null, exception: null, expected: null, actual: null); terminalReporter.TestCompleted(testNodeUid: "CanceledTest1", "CanceledTest1", TestOutcome.Canceled, TimeSpan.FromSeconds(10), - informativeMessage: null, errorMessage: null, exception: null, expected: null, actual: null, standardOutput, errorOutput); + informativeMessage: null, errorMessage: null, exception: null, expected: null, actual: null); terminalReporter.TestCompleted(testNodeUid: "FailedTest1", "FailedTest1", TestOutcome.Fail, TimeSpan.FromSeconds(10), - informativeMessage: null, errorMessage: "Tests failed", exception: new StackTraceException(@$" at FailingTest() in {folder}codefile.cs:line 10"), expected: "ABC", actual: "DEF", standardOutput, errorOutput); + informativeMessage: null, errorMessage: "Tests failed", exception: new StackTraceException(@$" at FailingTest() in {folder}codefile.cs:line 10"), expected: "ABC", actual: "DEF"); terminalReporter.ArtifactAdded(outOfProcess: true, testName: null, @$"{folder}artifact1.txt"); terminalReporter.ArtifactAdded(outOfProcess: false, testName: null, @$"{folder}artifact2.txt"); terminalReporter.AssemblyRunCompleted(); @@ -144,25 +142,9 @@ public void NonAnsiTerminal_OutputFormattingIsCorrect() string expected = $""" passed PassedTest1 (10s 000ms) - Standard output - Hello! - Error output - Oh no! skipped SkippedTest1 (10s 000ms) - Standard output - Hello! - Error output - Oh no! failed (canceled) TimedoutTest1 (10s 000ms) - Standard output - Hello! - Error output - Oh no! failed (canceled) CanceledTest1 (10s 000ms) - Standard output - Hello! - Error output - Oh no! failed FailedTest1 (10s 000ms) Tests failed Expected @@ -170,10 +152,6 @@ Tests failed Actual DEF at FailingTest() in {folder}codefile.cs:10 - Standard output - Hello! - Error output - Oh no! Out of process file artifacts produced: - {folder}artifact1.txt @@ -217,20 +195,18 @@ public void SimpleAnsiTerminal_OutputFormattingIsCorrect() string folder = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? @"C:\work\" : "/mnt/work/"; terminalReporter.AssemblyRunStarted(); - string standardOutput = "Hello!"; - string errorOutput = "Oh no!"; terminalReporter.TestCompleted(testNodeUid: "PassedTest1", "PassedTest1", TestOutcome.Passed, TimeSpan.FromSeconds(10), - informativeMessage: null, errorMessage: null, exception: null, expected: null, actual: null, standardOutput, errorOutput); + informativeMessage: null, errorMessage: null, exception: null, expected: null, actual: null); terminalReporter.TestCompleted(testNodeUid: "SkippedTest1", "SkippedTest1", TestOutcome.Skipped, TimeSpan.FromSeconds(10), - informativeMessage: null, errorMessage: null, exception: null, expected: null, actual: null, standardOutput, errorOutput); + informativeMessage: null, errorMessage: null, exception: null, expected: null, actual: null); // timed out + canceled + failed should all report as failed in summary terminalReporter.TestCompleted(testNodeUid: "TimedoutTest1", "TimedoutTest1", TestOutcome.Timeout, TimeSpan.FromSeconds(10), - informativeMessage: null, errorMessage: null, exception: null, expected: null, actual: null, standardOutput, errorOutput); + informativeMessage: null, errorMessage: null, exception: null, expected: null, actual: null); terminalReporter.TestCompleted(testNodeUid: "CanceledTest1", "CanceledTest1", TestOutcome.Canceled, TimeSpan.FromSeconds(10), - informativeMessage: null, errorMessage: null, exception: null, expected: null, actual: null, standardOutput, errorOutput); + informativeMessage: null, errorMessage: null, exception: null, expected: null, actual: null); terminalReporter.TestCompleted(testNodeUid: "FailedTest1", "FailedTest1", TestOutcome.Fail, TimeSpan.FromSeconds(10), - informativeMessage: null, errorMessage: "Tests failed", exception: new StackTraceException(@$" at FailingTest() in {folder}codefile.cs:line 10"), expected: "ABC", actual: "DEF", standardOutput, errorOutput); + informativeMessage: null, errorMessage: "Tests failed", exception: new StackTraceException(@$" at FailingTest() in {folder}codefile.cs:line 10"), expected: "ABC", actual: "DEF"); terminalReporter.ArtifactAdded(outOfProcess: true, testName: null, @$"{folder}artifact1.txt"); terminalReporter.ArtifactAdded(outOfProcess: false, testName: null, @$"{folder}artifact2.txt"); terminalReporter.AssemblyRunCompleted(); @@ -240,37 +216,17 @@ public void SimpleAnsiTerminal_OutputFormattingIsCorrect() string expected = $""" ␛[32mpassed␛[m PassedTest1 ␛[90m(10s 000ms)␛[m - ␛[90m Standard output - ␛[90m Hello! - ␛[90m Error output - ␛[90m Oh no! - ␛[m␛[33mskipped␛[m SkippedTest1 ␛[90m(10s 000ms)␛[m - ␛[90m Standard output - ␛[90m Hello! - ␛[90m Error output - ␛[90m Oh no! - ␛[m␛[31mfailed (canceled)␛[m TimedoutTest1 ␛[90m(10s 000ms)␛[m - ␛[90m Standard output - ␛[90m Hello! - ␛[90m Error output - ␛[90m Oh no! - ␛[m␛[31mfailed (canceled)␛[m CanceledTest1 ␛[90m(10s 000ms)␛[m - ␛[90m Standard output - ␛[90m Hello! - ␛[90m Error output - ␛[90m Oh no! - ␛[m␛[31mfailed␛[m FailedTest1 ␛[90m(10s 000ms)␛[m + ␛[33mskipped␛[m SkippedTest1 ␛[90m(10s 000ms)␛[m + ␛[31mfailed (canceled)␛[m TimedoutTest1 ␛[90m(10s 000ms)␛[m + ␛[31mfailed (canceled)␛[m CanceledTest1 ␛[90m(10s 000ms)␛[m + ␛[31mfailed␛[m FailedTest1 ␛[90m(10s 000ms)␛[m ␛[31m Tests failed ␛[m␛[31m Expected ␛[31m ABC ␛[31m Actual ␛[31m DEF ␛[m␛[90m at FailingTest() in {folder}codefile.cs:10␛[90m - ␛[m␛[90m Standard output - ␛[90m Hello! - ␛[90m Error output - ␛[90m Oh no! - ␛[m + Out of process file artifacts produced: - {folder}artifact1.txt In process file artifacts produced: @@ -314,20 +270,18 @@ public void AnsiTerminal_OutputFormattingIsCorrect() string folderLinkNoSlash = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? @"C:/work" : "mnt/work"; terminalReporter.AssemblyRunStarted(); - string standardOutput = "Hello!"; - string errorOutput = "Oh no!"; terminalReporter.TestCompleted(testNodeUid: "PassedTest1", "PassedTest1", TestOutcome.Passed, TimeSpan.FromSeconds(10), - informativeMessage: null, errorMessage: null, exception: null, expected: null, actual: null, standardOutput, errorOutput); + informativeMessage: null, errorMessage: null, exception: null, expected: null, actual: null); terminalReporter.TestCompleted(testNodeUid: "SkippedTest1", "SkippedTest1", TestOutcome.Skipped, TimeSpan.FromSeconds(10), - informativeMessage: null, errorMessage: null, exception: null, expected: null, actual: null, standardOutput, errorOutput); + informativeMessage: null, errorMessage: null, exception: null, expected: null, actual: null); // timed out + canceled + failed should all report as failed in summary terminalReporter.TestCompleted(testNodeUid: "TimedoutTest1", "TimedoutTest1", TestOutcome.Timeout, TimeSpan.FromSeconds(10), - informativeMessage: null, errorMessage: null, exception: null, expected: null, actual: null, standardOutput, errorOutput); + informativeMessage: null, errorMessage: null, exception: null, expected: null, actual: null); terminalReporter.TestCompleted(testNodeUid: "CanceledTest1", "CanceledTest1", TestOutcome.Canceled, TimeSpan.FromSeconds(10), - informativeMessage: null, errorMessage: null, exception: null, expected: null, actual: null, standardOutput, errorOutput); + informativeMessage: null, errorMessage: null, exception: null, expected: null, actual: null); terminalReporter.TestCompleted(testNodeUid: "FailedTest1", "FailedTest1", TestOutcome.Fail, TimeSpan.FromSeconds(10), - informativeMessage: null, errorMessage: "Tests failed", exception: new StackTraceException(@$" at FailingTest() in {folder}codefile.cs:line 10"), expected: "ABC", actual: "DEF", standardOutput, errorOutput); + informativeMessage: null, errorMessage: "Tests failed", exception: new StackTraceException(@$" at FailingTest() in {folder}codefile.cs:line 10"), expected: "ABC", actual: "DEF"); terminalReporter.ArtifactAdded(outOfProcess: true, testName: null, @$"{folder}artifact1.txt"); terminalReporter.ArtifactAdded(outOfProcess: false, testName: null, @$"{folder}artifact2.txt"); terminalReporter.AssemblyRunCompleted(); @@ -337,37 +291,17 @@ public void AnsiTerminal_OutputFormattingIsCorrect() string expected = $""" ␛[32mpassed␛[m PassedTest1 ␛[90m(10s 000ms)␛[m - ␛[90m Standard output - Hello! - Error output - Oh no! - ␛[m␛[33mskipped␛[m SkippedTest1 ␛[90m(10s 000ms)␛[m - ␛[90m Standard output - Hello! - Error output - Oh no! - ␛[m␛[31mfailed (canceled)␛[m TimedoutTest1 ␛[90m(10s 000ms)␛[m - ␛[90m Standard output - Hello! - Error output - Oh no! - ␛[m␛[31mfailed (canceled)␛[m CanceledTest1 ␛[90m(10s 000ms)␛[m - ␛[90m Standard output - Hello! - Error output - Oh no! - ␛[m␛[31mfailed␛[m FailedTest1 ␛[90m(10s 000ms)␛[m + ␛[33mskipped␛[m SkippedTest1 ␛[90m(10s 000ms)␛[m + ␛[31mfailed (canceled)␛[m TimedoutTest1 ␛[90m(10s 000ms)␛[m + ␛[31mfailed (canceled)␛[m CanceledTest1 ␛[90m(10s 000ms)␛[m + ␛[31mfailed␛[m FailedTest1 ␛[90m(10s 000ms)␛[m ␛[31m Tests failed ␛[m␛[31m Expected ABC Actual DEF ␛[m␛[90m at FailingTest() in ␛[90m␛]8;;file:///{folderLink}codefile.cs␛\{folder}codefile.cs:10␛]8;;␛\␛[m␛[90m - ␛[m␛[90m Standard output - Hello! - Error output - Oh no! - ␛[m + Out of process file artifacts produced: - ␛[90m␛]8;;file:///{folderLink}artifact1.txt␛\{folder}artifact1.txt␛]8;;␛\␛[m In process file artifacts produced: @@ -421,8 +355,6 @@ public void AnsiTerminal_OutputProgressFrameIsCorrect() string folder = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? @"C:\work\" : "/mnt/work/"; terminalReporter.AssemblyRunStarted(); - string standardOutput = "Hello!"; - string errorOutput = "Oh no!"; // Note: Add 1ms to make the order of the progress frame deterministic. // Otherwise all tests that run for 1m31s could show in any order. @@ -438,9 +370,9 @@ public void AnsiTerminal_OutputProgressFrameIsCorrect() stopwatchFactory.AddTime(TimeSpan.FromSeconds(1)); terminalReporter.TestCompleted(testNodeUid: "PassedTest1", "PassedTest1", TestOutcome.Passed, TimeSpan.FromSeconds(10), - informativeMessage: null, errorMessage: null, exception: null, expected: null, actual: null, standardOutput, errorOutput); + informativeMessage: null, errorMessage: null, exception: null, expected: null, actual: null); terminalReporter.TestCompleted(testNodeUid: "SkippedTest1", "SkippedTest1", TestOutcome.Skipped, TimeSpan.FromSeconds(10), - informativeMessage: null, errorMessage: null, exception: null, expected: null, actual: null, standardOutput, errorOutput); + informativeMessage: null, errorMessage: null, exception: null, expected: null, actual: null); string output = stringBuilderConsole.Output; startHandle.Set(); @@ -453,11 +385,7 @@ public void AnsiTerminal_OutputProgressFrameIsCorrect() // Note: The progress is drawn after each completed event. string expected = $""" {busyIndicatorString}␛[?25l␛[32mpassed␛[m PassedTest1 ␛[90m(10s 000ms)␛[m - ␛[90m Standard output - Hello! - Error output - Oh no! - ␛[m + [␛[32m✓1␛[m/␛[31mx0␛[m/␛[33m↓0␛[m] assembly.dll (net8.0|x64)␛[242G(1m 31s) SkippedTest1␛[242G(1m 31s) InProgressTest1␛[242G(1m 31s) @@ -465,11 +393,7 @@ Oh no! InProgressTest3␛[246G(1s) ␛[7F ␛[J␛[33mskipped␛[m SkippedTest1 ␛[90m(10s 000ms)␛[m - ␛[90m Standard output - Hello! - Error output - Oh no! - ␛[m + [␛[32m✓1␛[m/␛[31mx0␛[m/␛[33m↓1␛[m] assembly.dll (net8.0|x64)␛[242G(1m 31s) InProgressTest1␛[242G(1m 31s) InProgressTest2␛[245G(31s) @@ -748,7 +672,7 @@ public void TestDisplayNames_WithControlCharacters_AreNormalized(char controlCha // Test display name with the specific control character string testDisplayName = $"Test{controlChar}Name"; terminalReporter.TestCompleted(testNodeUid: "Test1", testDisplayName, TestOutcome.Passed, TimeSpan.FromSeconds(1), - informativeMessage: null, errorMessage: null, exception: null, expected: null, actual: null, standardOutput: null, errorOutput: null); + informativeMessage: null, errorMessage: null, exception: null, expected: null, actual: null); terminalReporter.AssemblyRunCompleted(); terminalReporter.TestExecutionCompleted(endTime); @@ -983,7 +907,7 @@ public void AnsiTerminal_ProgressFrame_UseWindowWidthForCursorPositioning_WhenBu stopwatchFactory.AddTime(TimeSpan.FromMinutes(1) + TimeSpan.FromSeconds(31)); terminalReporter.TestCompleted(testNodeUid: "Test1", "Test1", TestOutcome.Passed, TimeSpan.FromSeconds(10), - informativeMessage: null, errorMessage: null, exception: null, expected: null, actual: null, standardOutput: null, errorOutput: null); + informativeMessage: null, errorMessage: null, exception: null, expected: null, actual: null); string output = stringBuilderConsole.Output; startHandle.Set(); From bfd156290d2b6a646f5ea5c55296a94d2a007d47 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Tue, 24 Mar 2026 14:27:07 +0100 Subject: [PATCH 3/4] Fix test expectations for terminal output formatting after stdout/stderr removal (#7601) Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Youssef1313 <31348972+Youssef1313@users.noreply.github.com> --- .../OutputDevice/Terminal/TerminalTestReporterTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs b/test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs index e1f5b120f7..9a7df32cab 100644 --- a/test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs +++ b/test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs @@ -226,7 +226,7 @@ public void SimpleAnsiTerminal_OutputFormattingIsCorrect() ␛[31m Actual ␛[31m DEF ␛[m␛[90m at FailingTest() in {folder}codefile.cs:10␛[90m - + ␛[m Out of process file artifacts produced: - {folder}artifact1.txt In process file artifacts produced: @@ -301,7 +301,7 @@ public void AnsiTerminal_OutputFormattingIsCorrect() Actual DEF ␛[m␛[90m at FailingTest() in ␛[90m␛]8;;file:///{folderLink}codefile.cs␛\{folder}codefile.cs:10␛]8;;␛\␛[m␛[90m - + ␛[m Out of process file artifacts produced: - ␛[90m␛]8;;file:///{folderLink}artifact1.txt␛\{folder}artifact1.txt␛]8;;␛\␛[m In process file artifacts produced: From a1c686e84f78713e83133f105c754c6dbc6893b9 Mon Sep 17 00:00:00 2001 From: Youssef Victor Date: Tue, 24 Mar 2026 15:16:08 +0100 Subject: [PATCH 4/4] Delete irrelevant test --- .../OutputTests.cs | 82 ------------------- 1 file changed, 82 deletions(-) delete mode 100644 test/IntegrationTests/MSTest.Acceptance.IntegrationTests/OutputTests.cs diff --git a/test/IntegrationTests/MSTest.Acceptance.IntegrationTests/OutputTests.cs b/test/IntegrationTests/MSTest.Acceptance.IntegrationTests/OutputTests.cs deleted file mode 100644 index 87a3c97e05..0000000000 --- a/test/IntegrationTests/MSTest.Acceptance.IntegrationTests/OutputTests.cs +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using Microsoft.Testing.Platform.Acceptance.IntegrationTests; -using Microsoft.Testing.Platform.Acceptance.IntegrationTests.Helpers; - -namespace MSTest.Acceptance.IntegrationTests; - -[TestClass] -public sealed class OutputTests : AcceptanceTestBase -{ - [TestMethod] - [DynamicData(nameof(TargetFrameworks.AllForDynamicData), typeof(TargetFrameworks))] - public async Task DetailedOutputIsAsExpected(string tfm) - { - var testHost = TestHost.LocateFrom(AssetFixture.ProjectPath, TestAssetFixture.ProjectName, tfm); - TestHostResult testHostResult = await testHost.ExecuteAsync("--output detailed", cancellationToken: TestContext.CancellationToken); - - // Assert - testHostResult.AssertOutputContains("Assert.AreEqual failed. Expected:<1>. Actual:<2>."); - testHostResult.AssertOutputContains(""" - Standard output - Console message - TestContext Messages: - TestContext message - Error output - """); - } - - public sealed class TestAssetFixture() : TestAssetFixtureBase(AcceptanceFixture.NuGetGlobalPackagesFolder) - { - public const string ProjectName = "TestOutput"; - - public string ProjectPath => GetAssetPath(ProjectName); - - public override (string ID, string Name, string Code) GetAssetsToGenerate() => (ProjectName, ProjectName, - SourceCode - .PatchTargetFrameworks(TargetFrameworks.All) - .PatchCodeWithReplace("$MSTestVersion$", MSTestVersion)); - - private const string SourceCode = """ -#file TestOutput.csproj - - - - Exe - true - $TargetFrameworks$ - - - - - - - - - -#file UnitTest1.cs -using System; -using System.Diagnostics; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -[TestClass] -public class UnitTest1 -{ - public TestContext TestContext { get; set; } - - [TestMethod] - public void TestMethod() - { - Debug.WriteLine("Debug message"); - Console.WriteLine("Console message"); - TestContext.WriteLine("TestContext message"); - - Assert.AreEqual(1, 2); - } -} -"""; - } - - public TestContext TestContext { get; set; } -}