From 7264afa0720d846bc4d64efaf5ebe9587e071ca7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Jare=C5=A1?= Date: Thu, 20 Jun 2024 14:45:58 +0200 Subject: [PATCH] Error output as info in terminal logger (#5113) --- .../Tasks/VSTestTask2.cs | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/Microsoft.TestPlatform.Build/Tasks/VSTestTask2.cs b/src/Microsoft.TestPlatform.Build/Tasks/VSTestTask2.cs index 44eab60c86..9801603af0 100644 --- a/src/Microsoft.TestPlatform.Build/Tasks/VSTestTask2.cs +++ b/src/Microsoft.TestPlatform.Build/Tasks/VSTestTask2.cs @@ -101,17 +101,11 @@ protected override void LogEventsFromTextOutput(string singleLine, MessageImport break; case "output-error": { + // Downgrade errors to info messages, xUnit outputs every assertion failure and it confuses users who see doubled error count. + // Libraries write to error output, and don't expect tests to fail. + // Logs are often written to error stream as well. var error = data[0]; - if (error != null && error.StartsWith("[xUnit.net", StringComparison.OrdinalIgnoreCase)) - { - // Downgrade errors from xunit, because they will end up being duplicated on screen with assertion errors. - // And we end up with more errors in summary which is hard to figure out for users. - LogMSBuildOutputMessage(error); - } - else - { - Log.LogError(data[0]); - } + LogMSBuildOutputMessage(error); break; } @@ -248,9 +242,14 @@ protected override void LogEventsFromTextOutput(string singleLine, MessageImport } } - private void LogMSBuildOutputMessage(string singleLine) + private void LogMSBuildOutputMessage(string? singleLine) { + if (singleLine == null) + { + return; + } + var message = new ExtendedBuildMessageEventArgs("TLTESTOUTPUT", singleLine, null, null, MessageImportance.High); BuildEngine.LogMessageEvent(message); }