diff --git a/src/xunit.runner.visualstudio/Sinks/VsDiscoverySink.cs b/src/xunit.runner.visualstudio/Sinks/VsDiscoverySink.cs index acd27ed..51d8f56 100644 --- a/src/xunit.runner.visualstudio/Sinks/VsDiscoverySink.cs +++ b/src/xunit.runner.visualstudio/Sinks/VsDiscoverySink.cs @@ -94,6 +94,9 @@ public void Dispose() => result.SetPropertyValue(VsTestRunner.ManagedTypeProperty, testCase.TestClassName); result.SetPropertyValue(VsTestRunner.ManagedMethodProperty, managedMethodName); + if (testCase.SkipReason is not null) + result.SetPropertyValue(VsTestRunner.SkipReasonProperty, testCase.SkipReason); + if (testPlatformContext.DesignMode) result.SetPropertyValue(VsTestRunner.TestCaseSerializationProperty, testCase.Serialization); diff --git a/src/xunit.runner.visualstudio/VsTestRunner.cs b/src/xunit.runner.visualstudio/VsTestRunner.cs index 7946579..1b6b609 100644 --- a/src/xunit.runner.visualstudio/VsTestRunner.cs +++ b/src/xunit.runner.visualstudio/VsTestRunner.cs @@ -126,6 +126,9 @@ public class VsTestRunner : ITestDiscoverer, ITestExecutor public static TestProperty ManagedTypeProperty { get; } = TestProperty.Register("TestCase.ManagedType", "ManagedType", string.Empty, string.Empty, typeof(string), x => !string.IsNullOrWhiteSpace(x as string), TestPropertyAttributes.Hidden, typeof(TestCase)); + public static TestProperty SkipReasonProperty { get; } = + TestProperty.Register("XunitSkipReason", "xUnit.net Skip Reason", typeof(string), typeof(VsTestRunner)); + public static TestProperty TestCaseExplicitProperty { get; } = TestProperty.Register("XunitTestCaseExplicit", "xUnit.net Test Case Explicit Flag", typeof(bool), typeof(VsTestRunner)); diff --git a/test/test.xunit.runner.visualstudio/Sinks/VsDiscoverySinkTests.cs b/test/test.xunit.runner.visualstudio/Sinks/VsDiscoverySinkTests.cs index ac46ddc..f32769d 100644 --- a/test/test.xunit.runner.visualstudio/Sinks/VsDiscoverySinkTests.cs +++ b/test/test.xunit.runner.visualstudio/Sinks/VsDiscoverySinkTests.cs @@ -81,5 +81,16 @@ public void SetsManagedTypeAndMethodProperties( Assert.Equal("test-class-name", vsTestCase.GetPropertyValue(VsTestRunner.ManagedTypeProperty)); Assert.Equal(expectedManagedMethodName, vsTestCase.GetPropertyValue(VsTestRunner.ManagedMethodProperty)); } + + [Fact] + public void SetsSkipReason() + { + var testCase = TestData.TestCaseDiscovered(skipReason: "the-skip-reason"); + + var vsTestCase = VsDiscoverySink.CreateVsTestCase("source", testCase, logger, testPlatformContext); + + Assert.NotNull(vsTestCase); + Assert.Equal("the-skip-reason", vsTestCase.GetPropertyValue(VsTestRunner.SkipReasonProperty)); + } } }