From c29a7604e9c7bd6166006e55e4d93abc811bf404 Mon Sep 17 00:00:00 2001 From: Brad Wilson Date: Fri, 30 Jun 2023 21:57:49 -0700 Subject: [PATCH] #110: Visual Studio test explorer cannot filter skipped tests by message --- src/xunit.runner.visualstudio/Sinks/VsExecutionSink.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/xunit.runner.visualstudio/Sinks/VsExecutionSink.cs b/src/xunit.runner.visualstudio/Sinks/VsExecutionSink.cs index 4ef9dac3..ccff00f5 100644 --- a/src/xunit.runner.visualstudio/Sinks/VsExecutionSink.cs +++ b/src/xunit.runner.visualstudio/Sinks/VsExecutionSink.cs @@ -264,14 +264,15 @@ void WriteError( VsTestResult? MakeVsTestResult( TestOutcome outcome, ITestSkipped skippedResult) => - MakeVsTestResult(outcome, skippedResult.TestCase, skippedResult.Test.DisplayName, (double)skippedResult.ExecutionTime, skippedResult.Reason); + MakeVsTestResult(outcome, skippedResult.TestCase, skippedResult.Test.DisplayName, (double)skippedResult.ExecutionTime, errorMessage: skippedResult.Reason); VsTestResult? MakeVsTestResult( TestOutcome outcome, ITestCase testCase, string displayName, double executionTime = 0.0, - string? output = null) + string? output = null, + string? errorMessage = null) { var vsTestCase = FindTestCase(testCase); if (vsTestCase == null) @@ -292,6 +293,9 @@ void WriteError( if (!string.IsNullOrEmpty(output)) result.Messages.Add(new VsTestResultMessage(VsTestResultMessage.StandardOutCategory, output)); + if (!string.IsNullOrEmpty(errorMessage)) + result.ErrorMessage = errorMessage; + return result; }