From 4c9bf8e53a77e1db5d9b88f7489fb69774bb4f44 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Mon, 13 Mar 2023 23:27:57 +0100 Subject: [PATCH] Fix platform fact/theory attributes. Throwing on `Skip` setter was causing all subsequent tests in class to be ignored. --- .../PlatformFactAttribute.cs | 13 +++++++++++-- .../PlatformTheoryAttribute.cs | 11 +++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/tests/Avalonia.IntegrationTests.Appium/PlatformFactAttribute.cs b/tests/Avalonia.IntegrationTests.Appium/PlatformFactAttribute.cs index 3acf9fd5e2..17c42216e9 100644 --- a/tests/Avalonia.IntegrationTests.Appium/PlatformFactAttribute.cs +++ b/tests/Avalonia.IntegrationTests.Appium/PlatformFactAttribute.cs @@ -17,6 +17,7 @@ namespace Avalonia internal class PlatformFactAttribute : FactAttribute { private readonly string? _reason; + private string? _skip; public PlatformFactAttribute(TestPlatforms platforms, string? reason = null) { @@ -28,8 +29,16 @@ namespace Avalonia public override string? Skip { - get => IsSupported() ? null : $"Ignored on {RuntimeInformation.OSDescription}" + (_reason is not null ? $" reason: \"{_reason}\"" : ""); - set => throw new NotSupportedException(); + get + { + if (_skip is not null) + return _skip; + if (!IsSupported()) + return $"Ignored on {RuntimeInformation.OSDescription}" + + (_reason is not null ? $" reason: '{_reason}'" : ""); + return null; + } + set => _skip = value; } private bool IsSupported() diff --git a/tests/Avalonia.IntegrationTests.Appium/PlatformTheoryAttribute.cs b/tests/Avalonia.IntegrationTests.Appium/PlatformTheoryAttribute.cs index 7ac30ee11b..46a8e1af98 100644 --- a/tests/Avalonia.IntegrationTests.Appium/PlatformTheoryAttribute.cs +++ b/tests/Avalonia.IntegrationTests.Appium/PlatformTheoryAttribute.cs @@ -7,14 +7,21 @@ namespace Avalonia.IntegrationTests.Appium { internal class PlatformTheoryAttribute : TheoryAttribute { + private string? _skip; + public PlatformTheoryAttribute(TestPlatforms platforms = TestPlatforms.All) => Platforms = platforms; public TestPlatforms Platforms { get; } public override string? Skip { - get => IsSupported() ? null : $"Ignored on {RuntimeInformation.OSDescription}"; - set => throw new NotSupportedException(); + get + { + if (_skip is not null) + return _skip; + return !IsSupported() ? $"Ignored on {RuntimeInformation.OSDescription}" : null; + } + set => _skip = value; } private bool IsSupported()