Skip to content

Commit 7264afa

Browse files
authored
Error output as info in terminal logger (#5113)
1 parent 3d2ea06 commit 7264afa

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

src/Microsoft.TestPlatform.Build/Tasks/VSTestTask2.cs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -101,17 +101,11 @@ protected override void LogEventsFromTextOutput(string singleLine, MessageImport
101101
break;
102102
case "output-error":
103103
{
104+
// Downgrade errors to info messages, xUnit outputs every assertion failure and it confuses users who see doubled error count.
105+
// Libraries write to error output, and don't expect tests to fail.
106+
// Logs are often written to error stream as well.
104107
var error = data[0];
105-
if (error != null && error.StartsWith("[xUnit.net", StringComparison.OrdinalIgnoreCase))
106-
{
107-
// Downgrade errors from xunit, because they will end up being duplicated on screen with assertion errors.
108-
// And we end up with more errors in summary which is hard to figure out for users.
109-
LogMSBuildOutputMessage(error);
110-
}
111-
else
112-
{
113-
Log.LogError(data[0]);
114-
}
108+
LogMSBuildOutputMessage(error);
115109

116110
break;
117111
}
@@ -248,9 +242,14 @@ protected override void LogEventsFromTextOutput(string singleLine, MessageImport
248242
}
249243
}
250244

251-
private void LogMSBuildOutputMessage(string singleLine)
245+
private void LogMSBuildOutputMessage(string? singleLine)
252246
{
253247

248+
if (singleLine == null)
249+
{
250+
return;
251+
}
252+
254253
var message = new ExtendedBuildMessageEventArgs("TLTESTOUTPUT", singleLine, null, null, MessageImportance.High);
255254
BuildEngine.LogMessageEvent(message);
256255
}

0 commit comments

Comments
 (0)