From a3d721ad638a8888f1ec75d00d57a4a14c29930e Mon Sep 17 00:00:00 2001 From: "Surendran, Abhilash (SHS DI MR R&D SWI CFP)" Date: Thu, 10 Oct 2024 12:09:39 +0200 Subject: [PATCH 1/2] Skipped tests to be shown as skipped in vstest (former showing as success) --- Libraries/Catch2Interface/Reporter/OverallResult.cs | 7 +++++++ Libraries/Catch2Interface/TestResult.cs | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/Libraries/Catch2Interface/Reporter/OverallResult.cs b/Libraries/Catch2Interface/Reporter/OverallResult.cs index fba570d..3e94937 100644 --- a/Libraries/Catch2Interface/Reporter/OverallResult.cs +++ b/Libraries/Catch2Interface/Reporter/OverallResult.cs @@ -38,6 +38,7 @@ public class OverallResult public string StdErr { get; private set; } = string.Empty; public string StdOut { get; private set; } = string.Empty; public bool Success { get; private set; } = false; + public bool Skipped { get; private set; } = false; #endregion // Properties @@ -53,6 +54,12 @@ public OverallResult(XmlNode node) Success = Constants.Rgx_True.IsMatch(success); } + var skipped = node.Attributes["skips"]?.Value; + if (skipped != null && skipped == "1") + { + Skipped = true; + } + double duration = 0.0; if (double.TryParse(node.Attributes["durationInSeconds"]?.Value, _style, _culture, out duration)) { diff --git a/Libraries/Catch2Interface/TestResult.cs b/Libraries/Catch2Interface/TestResult.cs index a5b3186..cbfc5f3 100644 --- a/Libraries/Catch2Interface/TestResult.cs +++ b/Libraries/Catch2Interface/TestResult.cs @@ -96,6 +96,10 @@ public TestResult(Reporter.TestCase testcase, Settings settings, bool combined) Duration = _testcase.OverallResult.Duration; Name = _testcase.Name; Outcome = _testcase.OverallResult.Success ? TestOutcomes.Passed : TestOutcomes.Failed; + if(testcase.OverallResult.Skipped) + { + Outcome = TestOutcomes.Skipped; + } StandardOut = _testcase.OverallResult.StdOut; StandardError = _testcase.OverallResult.StdErr; @@ -420,6 +424,10 @@ void ExtractTestResult(XmlNode nodeGroup) _testcase = testcase; Outcome = _testcase.OverallResult.Success ? TestOutcomes.Passed : TestOutcomes.Failed; + if(_testcase.OverallResult.Skipped) + { + Outcome = TestOutcomes.Skipped; + } Duration = _testcase.OverallResult.Duration; StandardOut = _testcase.OverallResult.StdOut; StandardError = _testcase.OverallResult.StdErr; From ee15f1c123ada1306e4bb4a96e0fb5cef2b7610b Mon Sep 17 00:00:00 2001 From: Abhilash Surendran Date: Tue, 4 Feb 2025 13:54:41 +0100 Subject: [PATCH 2/2] Corrected review comments --- Libraries/Catch2Interface/Reporter/OverallResult.cs | 2 +- Libraries/Catch2Interface/TestResult.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Libraries/Catch2Interface/Reporter/OverallResult.cs b/Libraries/Catch2Interface/Reporter/OverallResult.cs index 3e94937..4c4dd5b 100644 --- a/Libraries/Catch2Interface/Reporter/OverallResult.cs +++ b/Libraries/Catch2Interface/Reporter/OverallResult.cs @@ -38,7 +38,7 @@ public class OverallResult public string StdErr { get; private set; } = string.Empty; public string StdOut { get; private set; } = string.Empty; public bool Success { get; private set; } = false; - public bool Skipped { get; private set; } = false; + public bool Skipped { get; private set; } = false; #endregion // Properties diff --git a/Libraries/Catch2Interface/TestResult.cs b/Libraries/Catch2Interface/TestResult.cs index cbfc5f3..3e51469 100644 --- a/Libraries/Catch2Interface/TestResult.cs +++ b/Libraries/Catch2Interface/TestResult.cs @@ -96,7 +96,7 @@ public TestResult(Reporter.TestCase testcase, Settings settings, bool combined) Duration = _testcase.OverallResult.Duration; Name = _testcase.Name; Outcome = _testcase.OverallResult.Success ? TestOutcomes.Passed : TestOutcomes.Failed; - if(testcase.OverallResult.Skipped) + if(_testcase.OverallResult.Skipped) { Outcome = TestOutcomes.Skipped; }