From 031991f32f059b64374e6d257cbe573304dd577f Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Fri, 13 May 2022 11:40:45 -0500 Subject: Add ability to skip tests at runtime, and skip long running cache tests 6665 --- .../XunitExtensions/SkippableFactTestCase.cs | 40 ++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/internal/WixBuildTools.TestSupport/XunitExtensions/SkippableFactTestCase.cs (limited to 'src/internal/WixBuildTools.TestSupport/XunitExtensions/SkippableFactTestCase.cs') diff --git a/src/internal/WixBuildTools.TestSupport/XunitExtensions/SkippableFactTestCase.cs b/src/internal/WixBuildTools.TestSupport/XunitExtensions/SkippableFactTestCase.cs new file mode 100644 index 00000000..f13fec83 --- /dev/null +++ b/src/internal/WixBuildTools.TestSupport/XunitExtensions/SkippableFactTestCase.cs @@ -0,0 +1,40 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixBuildTools.TestSupport.XunitExtensions +{ + using System; + using System.ComponentModel; + using System.Threading; + using System.Threading.Tasks; + using Xunit.Abstractions; + using Xunit.Sdk; + + public class SkippableFactTestCase : XunitTestCase + { + [EditorBrowsable(EditorBrowsableState.Never)] + [Obsolete("Called by the de-serializer; should only be called by deriving classes for de-serialization purposes")] + public SkippableFactTestCase() { } + + public SkippableFactTestCase(IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, ITestMethod testMethod, object[] testMethodArguments = null) + : base(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod, testMethodArguments) + { + } + + public override async Task RunAsync(IMessageSink diagnosticMessageSink, + IMessageBus messageBus, + object[] constructorArguments, + ExceptionAggregator aggregator, + CancellationTokenSource cancellationTokenSource) + { + var skipMessageBus = new SkippableFactMessageBus(messageBus); + var result = await base.RunAsync(diagnosticMessageSink, skipMessageBus, constructorArguments, aggregator, cancellationTokenSource); + if (skipMessageBus.DynamicallySkippedTestCount > 0) + { + result.Failed -= skipMessageBus.DynamicallySkippedTestCount; + result.Skipped += skipMessageBus.DynamicallySkippedTestCount; + } + + return result; + } + } +} -- cgit v1.2.3-55-g6feb