From f701df694c6349207c62171a7db64f871a32fe2c Mon Sep 17 00:00:00 2001 From: Marco Rossignoli Date: Tue, 3 Sep 2024 20:07:05 +0200 Subject: [PATCH] Fix missing skip reason (#3754) (#3755) --- .../TestingFramework/TestingFramework.Attributes.cs | 6 ++++++ .../TestingFramework/TestingFramework.cs | 5 +++-- .../Source/TestingPlatformExplorer/UnitTests.cs | 2 +- .../ServerMode/JsonRpc/Json/Json.cs | 7 ++++++- .../ServerMode/JsonRpc/SerializerUtilities.cs | 8 +++++++- 5 files changed, 23 insertions(+), 5 deletions(-) diff --git a/docs/testingplatform/Source/TestingPlatformExplorer/TestingFramework/TestingFramework.Attributes.cs b/docs/testingplatform/Source/TestingPlatformExplorer/TestingFramework/TestingFramework.Attributes.cs index c1c83b63a1..efa7adde16 100644 --- a/docs/testingplatform/Source/TestingPlatformExplorer/TestingFramework/TestingFramework.Attributes.cs +++ b/docs/testingplatform/Source/TestingPlatformExplorer/TestingFramework/TestingFramework.Attributes.cs @@ -6,6 +6,12 @@ namespace TestingPlatformExplorer.TestingFramework; [AttributeUsage(AttributeTargets.Method)] public class SkipAttribute : Attribute { + public string Reason { get; private set; } + + public SkipAttribute(string reason) + { + Reason = reason; + } } [AttributeUsage(AttributeTargets.Method)] diff --git a/docs/testingplatform/Source/TestingPlatformExplorer/TestingFramework/TestingFramework.cs b/docs/testingplatform/Source/TestingPlatformExplorer/TestingFramework/TestingFramework.cs index 191604e76c..63f5568838 100644 --- a/docs/testingplatform/Source/TestingPlatformExplorer/TestingFramework/TestingFramework.cs +++ b/docs/testingplatform/Source/TestingPlatformExplorer/TestingFramework/TestingFramework.cs @@ -152,13 +152,14 @@ public async Task ExecuteRequestAsync(ExecuteRequestContext context) } } - if (test.GetCustomAttribute() != null) + SkipAttribute? skipAttribute = test.GetCustomAttribute(); + if (skipAttribute != null) { var skippedTestNode = new TestNode() { Uid = $"{test.DeclaringType!.FullName}.{test.Name}", DisplayName = test.Name, - Properties = new PropertyBag(SkippedTestNodeStateProperty.CachedInstance), + Properties = new PropertyBag(new SkippedTestNodeStateProperty(skipAttribute.Reason)), }; if (_capabilities.TrxCapability.IsTrxEnabled) diff --git a/docs/testingplatform/Source/TestingPlatformExplorer/UnitTests.cs b/docs/testingplatform/Source/TestingPlatformExplorer/UnitTests.cs index e211f2f523..b96ab23e67 100644 --- a/docs/testingplatform/Source/TestingPlatformExplorer/UnitTests.cs +++ b/docs/testingplatform/Source/TestingPlatformExplorer/UnitTests.cs @@ -33,7 +33,7 @@ public static void TestMethod3(ITestOutputHelper testOutputHelper) } } - [Skip] + [Skip("Temporary disabled")] [TestMethod] public static void TestMethod4() => Assert.AreEqual(1, 1); } diff --git a/src/Platform/Microsoft.Testing.Platform/ServerMode/JsonRpc/Json/Json.cs b/src/Platform/Microsoft.Testing.Platform/ServerMode/JsonRpc/Json/Json.cs index 15cb3afd2b..a3aa049f3d 100644 --- a/src/Platform/Microsoft.Testing.Platform/ServerMode/JsonRpc/Json/Json.cs +++ b/src/Platform/Microsoft.Testing.Platform/ServerMode/JsonRpc/Json/Json.cs @@ -210,9 +210,14 @@ public Json(Dictionary? serializers = null, Dictionary