From 10397537d6006d06e2fedf68f30a99065d73d6df Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sun, 29 Dec 2024 17:16:46 -0700 Subject: [PATCH 01/27] Work toward xunit v3 --- .github/renovate.json | 4 +-- Directory.Packages.props | 4 +-- src/Xunit.StaFact/Sdk/StaFactDiscoverer.cs | 13 +--------- src/Xunit.StaFact/Sdk/UITestCase.cs | 25 +++++++++++++------ src/Xunit.StaFact/Xunit.StaFact.csproj | 2 +- .../Xunit.StaFact.Tests.Mac.csproj | 2 +- .../Xunit.StaFact.Tests.csproj | 3 ++- version.json | 2 +- 8 files changed, 27 insertions(+), 28 deletions(-) diff --git a/.github/renovate.json b/.github/renovate.json index fbd19309..c140014f 100644 --- a/.github/renovate.json +++ b/.github/renovate.json @@ -9,8 +9,8 @@ "groupName": "nbgv and nerdbank.gitversioning updates" }, { - "matchPackageNames": ["xunit.extensibility.execution", "xunit"], - "allowedVersions": "<=2.4.2" + "matchPackageNames": ["xunit*"], + "groupName": "xunit" }, { "matchDatasources": ["dotnet-version", "docker"], diff --git a/Directory.Packages.props b/Directory.Packages.props index 564996ae..503b8e23 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -7,13 +7,13 @@ - + - + diff --git a/src/Xunit.StaFact/Sdk/StaFactDiscoverer.cs b/src/Xunit.StaFact/Sdk/StaFactDiscoverer.cs index a0aa63bc..46315e14 100644 --- a/src/Xunit.StaFact/Sdk/StaFactDiscoverer.cs +++ b/src/Xunit.StaFact/Sdk/StaFactDiscoverer.cs @@ -11,16 +11,11 @@ namespace Xunit.Sdk; /// public class StaFactDiscoverer : FactDiscoverer { - private readonly IMessageSink diagnosticMessageSink; - /// /// Initializes a new instance of the class. /// - /// The diagnostic message sink. - public StaFactDiscoverer(IMessageSink diagnosticMessageSink) - : base(diagnosticMessageSink) + public StaFactDiscoverer() { - this.diagnosticMessageSink = diagnosticMessageSink; } /// @@ -31,12 +26,6 @@ protected override IXunitTestCase CreateTestCase(ITestFrameworkDiscoveryOptions throw new ArgumentNullException(nameof(testMethod)); } - if (testMethod.Method.ReturnType.Name == "System.Void" && - testMethod.Method.GetCustomAttributes(typeof(AsyncStateMachineAttribute)).Any()) - { - return new ExecutionErrorTestCase(this.diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), TestMethodDisplayOptions.None, testMethod, "Async void methods are not supported."); - } - UISettingsAttribute settings = UIFactDiscoverer.GetSettings(testMethod); return RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? new UITestCase(UITestCase.SyncContextType.None, this.diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod, testMethodArguments: null, settings) diff --git a/src/Xunit.StaFact/Sdk/UITestCase.cs b/src/Xunit.StaFact/Sdk/UITestCase.cs index 93f6a047..19eb3a55 100644 --- a/src/Xunit.StaFact/Sdk/UITestCase.cs +++ b/src/Xunit.StaFact/Sdk/UITestCase.cs @@ -35,13 +35,22 @@ public UITestCase() /// The test settings to apply. /// The arguments for the test method. internal UITestCase( + UISettingsAttribute settings, SyncContextType synchronizationContextType, - IMessageSink diagnosticMessageSink, - TestMethodDisplay defaultMethodDisplay, - ITestMethod testMethod, - object?[]? testMethodArguments, - UISettingsAttribute settings) - : base(diagnosticMessageSink, defaultMethodDisplay, TestMethodDisplayOptions.None, testMethod, testMethodArguments) + IXunitTestMethod testMethod, + string testCaseDisplayName, + string uniqueID, + bool @explicit, + string? skipReason = null, + Type? skipType = null, + string? skipUnless = null, + string? skipWhen = null, + Dictionary>? traits = null, + object?[]? testMethodArguments = null, + string? sourceFilePath = null, + int? sourceLineNumber = null, + int? timeout = null) + : base(testMethod, testCaseDisplayName, uniqueID, @explicit, skipReason, skipType, skipUnless, skipWhen, traits, testMethodArguments, sourceFilePath, sourceLineNumber, timeout) { this.settings = settings; settings.ApplyTraits(this); @@ -82,7 +91,7 @@ public enum SyncContextType private SyncContextAdapter Adapter => GetAdapter(this.synchronizationContextType); - public override void Serialize(IXunitSerializationInfo data) + protected override void Serialize(IXunitSerializationInfo data) { if (data is null) { @@ -94,7 +103,7 @@ public override void Serialize(IXunitSerializationInfo data) data.AddValue(nameof(this.synchronizationContextType), this.synchronizationContextType); } - public override void Deserialize(IXunitSerializationInfo data) + protected override void Deserialize(IXunitSerializationInfo data) { if (data is null) { diff --git a/src/Xunit.StaFact/Xunit.StaFact.csproj b/src/Xunit.StaFact/Xunit.StaFact.csproj index 9c08d429..5985f924 100644 --- a/src/Xunit.StaFact/Xunit.StaFact.csproj +++ b/src/Xunit.StaFact/Xunit.StaFact.csproj @@ -37,6 +37,6 @@ Theory variants of these attributes allow for parameterized testing. Check out t - + diff --git a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj index 3a5795a3..1fc95b05 100644 --- a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj +++ b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj @@ -11,7 +11,7 @@ - + diff --git a/test/Xunit.StaFact.Tests/Xunit.StaFact.Tests.csproj b/test/Xunit.StaFact.Tests/Xunit.StaFact.Tests.csproj index ba399794..12c9dbf4 100644 --- a/test/Xunit.StaFact.Tests/Xunit.StaFact.Tests.csproj +++ b/test/Xunit.StaFact.Tests/Xunit.StaFact.Tests.csproj @@ -2,6 +2,7 @@ net8.0;net8.0-windows $(TargetFrameworks);net472 + Exe @@ -18,7 +19,7 @@ - + diff --git a/version.json b/version.json index d8262829..e5cda750 100644 --- a/version.json +++ b/version.json @@ -1,6 +1,6 @@ { "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json", - "version": "1.2-alpha", + "version": "2.0-alpha", "publicReleaseRefSpec": [ "^refs/heads/main$", "^refs/heads/v\\d+\\.\\d+$" From f8bfb6157eb63ec49bf5b53b4d19bb01d9ff421a Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sun, 29 Dec 2024 21:15:29 -0700 Subject: [PATCH 02/27] More work --- src/Xunit.StaFact/Sdk/StaTheoryDiscoverer.cs | 15 +-- src/Xunit.StaFact/Sdk/UIFactDiscoverer.cs | 6 +- src/Xunit.StaFact/Sdk/UITestCaseRunner.cs | 21 +-- src/Xunit.StaFact/Sdk/UITestInvoker.cs | 127 ------------------ src/Xunit.StaFact/Sdk/UITestRunner.cs | 128 ++++++++++++++++++- src/Xunit.StaFact/Usings.cs | 2 +- 6 files changed, 129 insertions(+), 170 deletions(-) delete mode 100644 src/Xunit.StaFact/Sdk/UITestInvoker.cs diff --git a/src/Xunit.StaFact/Sdk/StaTheoryDiscoverer.cs b/src/Xunit.StaFact/Sdk/StaTheoryDiscoverer.cs index 79b0a785..7c8cf2cf 100644 --- a/src/Xunit.StaFact/Sdk/StaTheoryDiscoverer.cs +++ b/src/Xunit.StaFact/Sdk/StaTheoryDiscoverer.cs @@ -14,9 +14,7 @@ public class StaTheoryDiscoverer : TheoryDiscoverer /// /// Initializes a new instance of the class. /// - /// The diagnostic message sink. - public StaTheoryDiscoverer(IMessageSink diagnosticMessageSink) - : base(diagnosticMessageSink) + public StaTheoryDiscoverer() { } @@ -27,12 +25,6 @@ protected override IEnumerable CreateTestCasesForDataRow(ITestFr throw new ArgumentNullException(nameof(testMethod)); } - if (testMethod.Method.ReturnType.Name == "System.Void" && - testMethod.Method.GetCustomAttributes(typeof(AsyncStateMachineAttribute)).Any()) - { - yield return new ExecutionErrorTestCase(this.DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), TestMethodDisplayOptions.None, testMethod, "Async void methods are not supported."); - } - UISettingsAttribute settings = UIFactDiscoverer.GetSettings(testMethod); yield return RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? new UITestCase(UITestCase.SyncContextType.None, this.DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod, dataRow, settings) @@ -46,11 +38,6 @@ protected override IEnumerable CreateTestCasesForTheory(ITestFra throw new ArgumentNullException(nameof(testMethod)); } - if (testMethod.Method.ReturnType.Name == "System.Void" && testMethod.Method.GetCustomAttributes(typeof(AsyncStateMachineAttribute)).Any()) - { - yield return new ExecutionErrorTestCase(this.DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), TestMethodDisplayOptions.None, testMethod, "Async void methods are not supported."); - } - UISettingsAttribute settings = UIFactDiscoverer.GetSettings(testMethod); yield return RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? new UITheoryTestCase(UITestCase.SyncContextType.None, this.DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), TestMethodDisplayOptions.None, testMethod, settings) diff --git a/src/Xunit.StaFact/Sdk/UIFactDiscoverer.cs b/src/Xunit.StaFact/Sdk/UIFactDiscoverer.cs index ff331be9..c5a9f59b 100644 --- a/src/Xunit.StaFact/Sdk/UIFactDiscoverer.cs +++ b/src/Xunit.StaFact/Sdk/UIFactDiscoverer.cs @@ -43,14 +43,14 @@ protected override IXunitTestCase CreateTestCase(ITestFrameworkDiscoveryOptions return new UITestCase(UITestCase.SyncContextType.Portable, this.diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod, testMethodArguments: null, settings); } - private static IEnumerable GetSettingsAttributes(ITestMethod testMethod) + private static IEnumerable GetSettingsAttributes(IXunitTestMethod testMethod) { - if (testMethod.TestClass.Class.GetCustomAttributes(typeof(UISettingsAttribute)).SingleOrDefault() is IAttributeInfo classLevel) + if (testMethod.TestClass.Class.GetCustomAttributes(typeof(UISettingsAttribute), true).SingleOrDefault() is UISettingsAttribute classLevel) { yield return classLevel; } - if (testMethod.Method.GetCustomAttributes(typeof(UISettingsAttribute)).SingleOrDefault() is IAttributeInfo methodLevel) + if (testMethod.Method.GetCustomAttributes(typeof(UISettingsAttribute), true).SingleOrDefault() is UISettingsAttribute methodLevel) { yield return methodLevel; } diff --git a/src/Xunit.StaFact/Sdk/UITestCaseRunner.cs b/src/Xunit.StaFact/Sdk/UITestCaseRunner.cs index f949b1a6..2532b779 100644 --- a/src/Xunit.StaFact/Sdk/UITestCaseRunner.cs +++ b/src/Xunit.StaFact/Sdk/UITestCaseRunner.cs @@ -11,36 +11,19 @@ public class UITestCaseRunner : XunitTestCaseRunner /// /// Initializes a new instance of the class. /// - /// The test case to be run. - /// The display name of the test case. - /// The skip reason, if the test is to be skipped. - /// The arguments to be passed to the test class constructor. - /// The arguments to be passed to the test method. - /// The message bus to report run status to. - /// The exception aggregator used to run code and collect exceptions. - /// The task cancellation token source, used to cancel the test run. /// The settings to use for this test case. /// The instance to use. internal UITestCaseRunner( - IXunitTestCase testCase, - string displayName, - string skipReason, - object[] constructorArguments, - object[] testMethodArguments, - IMessageBus messageBus, - ExceptionAggregator aggregator, - CancellationTokenSource cancellationTokenSource, UISettingsAttribute settings, ThreadRental threadRental) - : base(testCase, displayName, skipReason, constructorArguments, testMethodArguments, messageBus, aggregator, cancellationTokenSource) { this.settings = settings; this.threadRental = threadRental; } - protected override async Task RunTestAsync() + protected override async ValueTask RunTest(XunitTestCaseRunnerContext ctxt, IXunitTest test) { - RunSummary result = new(); + RunSummary result = default; for (int i = 0; i < this.settings.MaxAttempts; i++) { bool finalAttempt = i == this.settings.MaxAttempts - 1; diff --git a/src/Xunit.StaFact/Sdk/UITestInvoker.cs b/src/Xunit.StaFact/Sdk/UITestInvoker.cs deleted file mode 100644 index 4286d6b2..00000000 --- a/src/Xunit.StaFact/Sdk/UITestInvoker.cs +++ /dev/null @@ -1,127 +0,0 @@ -// Copyright (c) Andrew Arnott. All rights reserved. -// Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. - -using System.Reflection; - -namespace Xunit.Sdk; - -public class UITestInvoker : XunitTestInvoker -{ - private readonly ThreadRental threadRental; - - /// - /// Initializes a new instance of the class. - /// - internal UITestInvoker(ITest test, IMessageBus messageBus, Type testClass, object[] constructorArguments, MethodInfo testMethod, object[] testMethodArguments, IReadOnlyList beforeAfterAttributes, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource, ThreadRental threadRental) - : base(test, messageBus, testClass, constructorArguments, testMethod, testMethodArguments, beforeAfterAttributes, aggregator, cancellationTokenSource) - { - this.threadRental = threadRental; - } - - public new async Task RunAsync() - { - if (this.threadRental.SynchronizationContext is UISynchronizationContext syncContext) - { - syncContext.SetExceptionAggregator(this.Aggregator); - } - - await this.Aggregator.RunAsync(async delegate - { - if (!this.CancellationTokenSource.IsCancellationRequested) - { - await this.threadRental.SynchronizationContext; - var testClassInstance = this.CreateTestClass(); - - try - { - var asyncLifetime = testClassInstance as IAsyncLifetime; - if (asyncLifetime is object) - { - await this.threadRental.SynchronizationContext; - await asyncLifetime.InitializeAsync(); - } - - if (!this.CancellationTokenSource.IsCancellationRequested) - { - await this.threadRental.SynchronizationContext; - await this.Aggregator.RunAsync(this.BeforeTestMethodInvokedAsync); - - if (!this.Aggregator.HasExceptions) - { - if (!this.CancellationTokenSource.IsCancellationRequested) - { - await this.Timer.AggregateAsync( - async () => - { - var parameterCount = this.TestMethod.GetParameters().Length; - var valueCount = this.TestMethodArguments == null ? 0 : this.TestMethodArguments.Length; - if (parameterCount != valueCount) - { - this.Aggregator.Add( - new InvalidOperationException( - $"The test method expected {parameterCount} parameter value{(parameterCount == 1 ? string.Empty : "s")}, but {valueCount} parameter value{(valueCount == 1 ? string.Empty : "s")} {(valueCount == 1 ? "was" : "were")} provided.")); - } - else - { - await this.threadRental.SynchronizationContext; - object? result = null; - try - { - result = this.CallTestMethod(testClassInstance); - } - catch (TargetInvocationException ex) - { - this.Aggregator.Add(ex.InnerException); - } - - if (result is Task task) - { - await task.NoThrowAwaitable(); - if (task.IsFaulted) - { - this.Aggregator.Add(task.Exception!.Flatten().InnerException ?? task.Exception); - } - else if (task.IsCanceled) - { - try - { - // In order to get the original exception, in order to preserve the callstack, - // we must "rethrow" the exception. - task.GetAwaiter().GetResult(); - } - catch (OperationCanceledException ex) - { - this.Aggregator.Add(ex); - } - } - } - else if (this.threadRental.SyncContextAdapter.CanCompleteOperations) - { - await this.threadRental.SyncContextAdapter.WaitForOperationCompletionAsync(this.threadRental.SynchronizationContext).ConfigureAwait(false); - } - } - }); - } - - await this.threadRental.SynchronizationContext; - await this.Aggregator.RunAsync(this.AfterTestMethodInvokedAsync); - } - } - - if (asyncLifetime is object) - { - await this.threadRental.SynchronizationContext; - await this.Aggregator.RunAsync(asyncLifetime.DisposeAsync); - } - } - finally - { - await this.threadRental.SynchronizationContext; - this.Aggregator.Run(() => this.Test.DisposeTestClass(testClassInstance, this.MessageBus, this.Timer, this.CancellationTokenSource)); - } - } - }); - - return this.Timer.Total; - } -} diff --git a/src/Xunit.StaFact/Sdk/UITestRunner.cs b/src/Xunit.StaFact/Sdk/UITestRunner.cs index f7379b2e..34916b85 100644 --- a/src/Xunit.StaFact/Sdk/UITestRunner.cs +++ b/src/Xunit.StaFact/Sdk/UITestRunner.cs @@ -10,15 +10,116 @@ public class UITestRunner : XunitTestRunner { private readonly ThreadRental threadRental; - internal UITestRunner(ITest test, IMessageBus messageBus, bool finalAttempt, Type testClass, object[] constructorArguments, MethodInfo testMethod, object[] testMethodArguments, string skipReason, IReadOnlyList beforeAfterAttributes, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource, ThreadRental threadRental) - : base(test, finalAttempt ? messageBus : new FilteringMessageBus(messageBus), testClass, constructorArguments, testMethod, testMethodArguments, skipReason, beforeAfterAttributes, aggregator, cancellationTokenSource) + internal UITestRunner(ThreadRental threadRental) { this.threadRental = threadRental; } - protected override Task InvokeTestMethodAsync(ExceptionAggregator aggregator) + protected override async ValueTask InvokeTest(XunitTestRunnerContext ctxt, object? testClassInstance) { - return new UITestInvoker(this.Test, this.MessageBus, this.TestClass, this.ConstructorArguments, this.TestMethod, this.TestMethodArguments, this.BeforeAfterAttributes, aggregator, this.CancellationTokenSource, this.threadRental).RunAsync(); + if (this.threadRental.SynchronizationContext is UISynchronizationContext syncContext) + { + syncContext.SetExceptionAggregator(ctxt.Aggregator); + } + + await ctxt.Aggregator.RunAsync(async delegate + { + if (!ctxt.CancellationTokenSource.IsCancellationRequested) + { + await this.threadRental.SynchronizationContext; + var testClassInstance = this.CreateTestClass(); + + try + { + var asyncLifetime = testClassInstance as IAsyncLifetime; + if (asyncLifetime is object) + { + await this.threadRental.SynchronizationContext; + await asyncLifetime.InitializeAsync(); + } + + if (!ctxt.CancellationTokenSource.IsCancellationRequested) + { + await this.threadRental.SynchronizationContext; + ctxt.RunBeforeAttributes(); + + if (!ctxt.Aggregator.HasExceptions) + { + if (!ctxt.CancellationTokenSource.IsCancellationRequested) + { + await this.Timer.AggregateAsync( + async () => + { + var parameterCount = this.TestMethod.GetParameters().Length; + var valueCount = this.TestMethodArguments == null ? 0 : this.TestMethodArguments.Length; + if (parameterCount != valueCount) + { + this.Aggregator.Add( + new InvalidOperationException( + $"The test method expected {parameterCount} parameter value{(parameterCount == 1 ? string.Empty : "s")}, but {valueCount} parameter value{(valueCount == 1 ? string.Empty : "s")} {(valueCount == 1 ? "was" : "were")} provided.")); + } + else + { + await this.threadRental.SynchronizationContext; + object? result = null; + try + { + result = this.CallTestMethod(testClassInstance); + } + catch (TargetInvocationException ex) + { + this.Aggregator.Add(ex.InnerException); + } + + if (result is Task task) + { + await task.NoThrowAwaitable(); + if (task.IsFaulted) + { + this.Aggregator.Add(task.Exception!.Flatten().InnerException ?? task.Exception); + } + else if (task.IsCanceled) + { + try + { + // In order to get the original exception, in order to preserve the callstack, + // we must "rethrow" the exception. + task.GetAwaiter().GetResult(); + } + catch (OperationCanceledException ex) + { + this.Aggregator.Add(ex); + } + } + } + else if (this.threadRental.SyncContextAdapter.CanCompleteOperations) + { + await this.threadRental.SyncContextAdapter.WaitForOperationCompletionAsync(this.threadRental.SynchronizationContext).ConfigureAwait(false); + } + } + }); + } + + await this.threadRental.SynchronizationContext; + ctxt.RunAfterAttributes(); + } + } + + if (asyncLifetime is object) + { + await this.threadRental.SynchronizationContext; + await ctxt.Aggregator.RunAsync(asyncLifetime.DisposeAsync); + } + } + finally + { + await this.threadRental.SynchronizationContext; + ctxt.Aggregator.Run(() => ctxt.Test.DisposeTestClass(testClassInstance, this.MessageBus, this.Timer, this.CancellationTokenSource)); + } + } + }); + + return this.Timer.Total; } private sealed class FilteringMessageBus : IMessageBus @@ -49,7 +150,7 @@ public bool QueueMessage(IMessageSinkMessage message) return this.messageBus.QueueMessage(message); static IMessageSinkMessage ReportFailure(string header, T message) - where T : ITestMessage, IFailureInformation + where T : ITestMessage, IErrorMetadata { // This test will run again; report it as skipped instead of failed. StringBuilder failures = new(); @@ -61,7 +162,22 @@ static IMessageSinkMessage ReportFailure(string header, T message) failures.AppendLine(message.StackTraces[i]); } - return new TestSkipped(message.Test, failures.ToString()); + IExecutionMetadata? executionMetadata = message as IExecutionMetadata; + ITestResultMessage? testResultMessage = message as ITestResultMessage; + return new TestSkipped + { + Reason = failures.ToString(), + AssemblyUniqueID = message.AssemblyUniqueID, + TestCollectionUniqueID = message.TestCollectionUniqueID, + TestClassUniqueID = message.TestClassUniqueID, + TestMethodUniqueID = message.TestMethodUniqueID, + TestUniqueID = message.TestUniqueID, + TestCaseUniqueID = message.TestCaseUniqueID, + Output = executionMetadata?.Output ?? string.Empty, + Warnings = executionMetadata?.Warnings ?? [], + ExecutionTime = executionMetadata?.ExecutionTime ?? 0, + FinishTime = testResultMessage?.FinishTime ?? DateTimeOffset.Now, + }; } } } diff --git a/src/Xunit.StaFact/Usings.cs b/src/Xunit.StaFact/Usings.cs index 9721c838..28d713c0 100644 --- a/src/Xunit.StaFact/Usings.cs +++ b/src/Xunit.StaFact/Usings.cs @@ -1,4 +1,4 @@ // Copyright (c) Andrew Arnott. All rights reserved. // Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. -global using Xunit.Abstractions; +global using Xunit.v3; From cf1e550f3529676c2f3408137009b18f2de3813e Mon Sep 17 00:00:00 2001 From: reduckted Date: Tue, 7 Jan 2025 21:52:11 +1000 Subject: [PATCH 03/27] Updated xunit.runner.console to v3 package. --- Directory.Packages.props | 2 +- test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 503b8e23..0c9849d4 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -7,7 +7,7 @@ - + diff --git a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj index 1fc95b05..0f19e957 100644 --- a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj +++ b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj @@ -10,7 +10,7 @@ $(PartialTargetPath)\Xunit.StaFact.Tests.Mac.dll - + From 25073fb32f665ac7b75c0a3ba98729e66146f12b Mon Sep 17 00:00:00 2001 From: reduckted Date: Tue, 7 Jan 2025 21:52:30 +1000 Subject: [PATCH 04/27] Removed azure-pipelines.yml from solution. --- Xunit.StaFact.sln | 1 - 1 file changed, 1 deletion(-) diff --git a/Xunit.StaFact.sln b/Xunit.StaFact.sln index c8fbed0c..41ddb792 100644 --- a/Xunit.StaFact.sln +++ b/Xunit.StaFact.sln @@ -9,7 +9,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution ProjectSection(SolutionItems) = preProject .editorconfig = .editorconfig .gitignore = .gitignore - azure-pipelines.yml = azure-pipelines.yml Directory.Build.props = Directory.Build.props Directory.Build.targets = Directory.Build.targets Directory.Packages.props = Directory.Packages.props From 0efd1f2422c608cc11b25bde58d156c4df2d437d Mon Sep 17 00:00:00 2001 From: reduckted Date: Tue, 7 Jan 2025 22:05:41 +1000 Subject: [PATCH 05/27] Updated `XunitTestCaseDiscoverer` attributes. --- src/Xunit.StaFact/Mac/CocoaFactAttribute.cs | 4 ++-- src/Xunit.StaFact/Mac/CocoaTheoryAttribute.cs | 4 ++-- src/Xunit.StaFact/StaFactAttribute.cs | 4 ++-- src/Xunit.StaFact/StaTheoryAttribute.cs | 4 ++-- src/Xunit.StaFact/UIFactAttribute.cs | 4 ++-- src/Xunit.StaFact/UITheoryAttribute.cs | 4 ++-- src/Xunit.StaFact/WindowsDesktop/WinFormsFactAttribute.cs | 4 ++-- src/Xunit.StaFact/WindowsDesktop/WinFormsTheoryAttribute.cs | 4 ++-- src/Xunit.StaFact/WindowsDesktop/WpfFactAttribute.cs | 4 ++-- src/Xunit.StaFact/WindowsDesktop/WpfTheoryAttribute.cs | 4 ++-- 10 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/Xunit.StaFact/Mac/CocoaFactAttribute.cs b/src/Xunit.StaFact/Mac/CocoaFactAttribute.cs index 32f34f5b..a1d720fb 100644 --- a/src/Xunit.StaFact/Mac/CocoaFactAttribute.cs +++ b/src/Xunit.StaFact/Mac/CocoaFactAttribute.cs @@ -1,4 +1,4 @@ -// Copyright (c) Andrew Arnott. All rights reserved. +// Copyright (c) Andrew Arnott. All rights reserved. // Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. using Xunit.Sdk; @@ -10,7 +10,7 @@ namespace Xunit; /// running on . /// [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] -[XunitTestCaseDiscoverer("Xunit.Sdk.CocoaFactDiscoverer", ThisAssembly.AssemblyName)] +[XunitTestCaseDiscoverer(typeof(CocoaFactDiscoverer))] public class CocoaFactAttribute : FactAttribute { } diff --git a/src/Xunit.StaFact/Mac/CocoaTheoryAttribute.cs b/src/Xunit.StaFact/Mac/CocoaTheoryAttribute.cs index 7a2ec440..dcd75dca 100644 --- a/src/Xunit.StaFact/Mac/CocoaTheoryAttribute.cs +++ b/src/Xunit.StaFact/Mac/CocoaTheoryAttribute.cs @@ -1,4 +1,4 @@ -// Copyright (c) Andrew Arnott. All rights reserved. +// Copyright (c) Andrew Arnott. All rights reserved. // Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. using Xunit.Sdk; @@ -10,7 +10,7 @@ namespace Xunit; /// running on . /// [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] -[XunitTestCaseDiscoverer("Xunit.Sdk.CocoaTheoryDiscoverer", ThisAssembly.AssemblyName)] +[XunitTestCaseDiscoverer(typeof(CocoaTheoryDiscoverer))] public class CocoaTheoryAttribute : TheoryAttribute { } diff --git a/src/Xunit.StaFact/StaFactAttribute.cs b/src/Xunit.StaFact/StaFactAttribute.cs index 55b387a9..8b982514 100644 --- a/src/Xunit.StaFact/StaFactAttribute.cs +++ b/src/Xunit.StaFact/StaFactAttribute.cs @@ -1,4 +1,4 @@ -// Copyright (c) Andrew Arnott. All rights reserved. +// Copyright (c) Andrew Arnott. All rights reserved. // Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. using Xunit.Sdk; @@ -15,7 +15,7 @@ namespace Xunit; /// To get an STA thread even after awaiting expressions, use . /// [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] -[XunitTestCaseDiscoverer("Xunit.Sdk.StaFactDiscoverer", ThisAssembly.AssemblyName)] +[XunitTestCaseDiscoverer(typeof(StaFactDiscoverer))] public class StaFactAttribute : FactAttribute { } diff --git a/src/Xunit.StaFact/StaTheoryAttribute.cs b/src/Xunit.StaFact/StaTheoryAttribute.cs index 4bd73c71..a62ce440 100644 --- a/src/Xunit.StaFact/StaTheoryAttribute.cs +++ b/src/Xunit.StaFact/StaTheoryAttribute.cs @@ -1,4 +1,4 @@ -// Copyright (c) Andrew Arnott. All rights reserved. +// Copyright (c) Andrew Arnott. All rights reserved. // Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. using Xunit.Sdk; @@ -15,7 +15,7 @@ namespace Xunit; /// To get an STA thread even after awaiting expressions, use . /// [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] -[XunitTestCaseDiscoverer("Xunit.Sdk.StaTheoryDiscoverer", ThisAssembly.AssemblyName)] +[XunitTestCaseDiscoverer(typeof(StaTheoryDiscoverer))] public class StaTheoryAttribute : TheoryAttribute { } diff --git a/src/Xunit.StaFact/UIFactAttribute.cs b/src/Xunit.StaFact/UIFactAttribute.cs index e28c293e..21980cca 100644 --- a/src/Xunit.StaFact/UIFactAttribute.cs +++ b/src/Xunit.StaFact/UIFactAttribute.cs @@ -1,4 +1,4 @@ -// Copyright (c) Andrew Arnott. All rights reserved. +// Copyright (c) Andrew Arnott. All rights reserved. // Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. using Xunit.Sdk; @@ -11,7 +11,7 @@ namespace Xunit; /// On Windows, the test runs on an STA thread. /// [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] -[XunitTestCaseDiscoverer("Xunit.Sdk.UIFactDiscoverer", ThisAssembly.AssemblyName)] +[XunitTestCaseDiscoverer(typeof(UIFactDiscoverer))] public class UIFactAttribute : FactAttribute { } diff --git a/src/Xunit.StaFact/UITheoryAttribute.cs b/src/Xunit.StaFact/UITheoryAttribute.cs index 6a5e4fa1..1c28e1e0 100644 --- a/src/Xunit.StaFact/UITheoryAttribute.cs +++ b/src/Xunit.StaFact/UITheoryAttribute.cs @@ -1,4 +1,4 @@ -// Copyright (c) Andrew Arnott. All rights reserved. +// Copyright (c) Andrew Arnott. All rights reserved. // Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. using Xunit.Sdk; @@ -11,7 +11,7 @@ namespace Xunit; /// On Windows, the test runs on an STA thread. /// [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] -[XunitTestCaseDiscoverer("Xunit.Sdk.UITheoryDiscoverer", ThisAssembly.AssemblyName)] +[XunitTestCaseDiscoverer(typeof(UITheoryDiscoverer))] public class UITheoryAttribute : TheoryAttribute { } diff --git a/src/Xunit.StaFact/WindowsDesktop/WinFormsFactAttribute.cs b/src/Xunit.StaFact/WindowsDesktop/WinFormsFactAttribute.cs index eb14ac8b..70437559 100644 --- a/src/Xunit.StaFact/WindowsDesktop/WinFormsFactAttribute.cs +++ b/src/Xunit.StaFact/WindowsDesktop/WinFormsFactAttribute.cs @@ -1,4 +1,4 @@ -// Copyright (c) Andrew Arnott. All rights reserved. +// Copyright (c) Andrew Arnott. All rights reserved. // Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. using Xunit.Sdk; @@ -11,7 +11,7 @@ namespace Xunit; /// Tests will be Skipped on non-Windows operating systems. /// [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] -[XunitTestCaseDiscoverer("Xunit.Sdk.WinFormsFactDiscoverer", ThisAssembly.AssemblyName)] +[XunitTestCaseDiscoverer(typeof(WinFormsFactDiscoverer))] public class WinFormsFactAttribute : FactAttribute { } diff --git a/src/Xunit.StaFact/WindowsDesktop/WinFormsTheoryAttribute.cs b/src/Xunit.StaFact/WindowsDesktop/WinFormsTheoryAttribute.cs index a368e159..94d44309 100644 --- a/src/Xunit.StaFact/WindowsDesktop/WinFormsTheoryAttribute.cs +++ b/src/Xunit.StaFact/WindowsDesktop/WinFormsTheoryAttribute.cs @@ -1,4 +1,4 @@ -// Copyright (c) Andrew Arnott. All rights reserved. +// Copyright (c) Andrew Arnott. All rights reserved. // Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. using Xunit.Sdk; @@ -11,7 +11,7 @@ namespace Xunit; /// Tests will be Skipped on non-Windows operating systems. /// [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] -[XunitTestCaseDiscoverer("Xunit.Sdk.WinFormsTheoryDiscoverer", ThisAssembly.AssemblyName)] +[XunitTestCaseDiscoverer(typeof(WinFormsTheoryDiscoverer))] public class WinFormsTheoryAttribute : TheoryAttribute { } diff --git a/src/Xunit.StaFact/WindowsDesktop/WpfFactAttribute.cs b/src/Xunit.StaFact/WindowsDesktop/WpfFactAttribute.cs index 4e016a85..89a87dd2 100644 --- a/src/Xunit.StaFact/WindowsDesktop/WpfFactAttribute.cs +++ b/src/Xunit.StaFact/WindowsDesktop/WpfFactAttribute.cs @@ -1,4 +1,4 @@ -// Copyright (c) Andrew Arnott. All rights reserved. +// Copyright (c) Andrew Arnott. All rights reserved. // Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. using System.Windows.Threading; @@ -12,7 +12,7 @@ namespace Xunit; /// Tests will be Skipped on non-Windows operating systems. /// [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] -[XunitTestCaseDiscoverer("Xunit.Sdk.WpfFactDiscoverer", ThisAssembly.AssemblyName)] +[XunitTestCaseDiscoverer(typeof(WpfFactDiscoverer))] public class WpfFactAttribute : FactAttribute { } diff --git a/src/Xunit.StaFact/WindowsDesktop/WpfTheoryAttribute.cs b/src/Xunit.StaFact/WindowsDesktop/WpfTheoryAttribute.cs index adee1228..f875dd3e 100644 --- a/src/Xunit.StaFact/WindowsDesktop/WpfTheoryAttribute.cs +++ b/src/Xunit.StaFact/WindowsDesktop/WpfTheoryAttribute.cs @@ -1,4 +1,4 @@ -// Copyright (c) Andrew Arnott. All rights reserved. +// Copyright (c) Andrew Arnott. All rights reserved. // Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. using System.Windows.Threading; @@ -12,7 +12,7 @@ namespace Xunit; /// Tests will be Skipped on non-Windows operating systems. /// [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] -[XunitTestCaseDiscoverer("Xunit.Sdk.WpfTheoryDiscoverer", ThisAssembly.AssemblyName)] +[XunitTestCaseDiscoverer(typeof(WpfTheoryDiscoverer))] public class WpfTheoryAttribute : TheoryAttribute { } From f1d491940343274f590accd3a67bb9d85ce18fc5 Mon Sep 17 00:00:00 2001 From: reduckted Date: Tue, 7 Jan 2025 22:22:50 +1000 Subject: [PATCH 06/27] Updated discoverer types. --- .../Sdk.Mac/CocoaFactDiscoverer.cs | 21 +++---------- .../Sdk.Mac/CocoaTheoryDiscoverer.cs | 21 +++++-------- .../WinFormsFactDiscoverer.cs | 23 ++++---------- .../WinFormsTheoryDiscoverer.cs | 31 ++++++++----------- .../Sdk.WindowsDesktop/WpfFactDiscoverer.cs | 23 ++++---------- .../Sdk.WindowsDesktop/WpfTheoryDiscoverer.cs | 31 ++++++++----------- src/Xunit.StaFact/Sdk/StaFactDiscoverer.cs | 15 +++------ src/Xunit.StaFact/Sdk/StaTheoryDiscoverer.cs | 23 ++++++-------- src/Xunit.StaFact/Sdk/UIFactDiscoverer.cs | 28 +++++------------ src/Xunit.StaFact/Sdk/UITheoryDiscoverer.cs | 23 ++++++-------- src/Xunit.StaFact/Sdk/UITheoryTestCase.cs | 6 ++-- src/Xunit.StaFact/UISettingsAttribute.cs | 4 +-- src/Xunit.StaFact/Usings.cs | 3 +- 13 files changed, 85 insertions(+), 167 deletions(-) diff --git a/src/Xunit.StaFact/Sdk.Mac/CocoaFactDiscoverer.cs b/src/Xunit.StaFact/Sdk.Mac/CocoaFactDiscoverer.cs index c7e3ab47..43e85c19 100644 --- a/src/Xunit.StaFact/Sdk.Mac/CocoaFactDiscoverer.cs +++ b/src/Xunit.StaFact/Sdk.Mac/CocoaFactDiscoverer.cs @@ -1,4 +1,4 @@ -// Copyright (c) Andrew Arnott. All rights reserved. +// Copyright (c) Andrew Arnott. All rights reserved. // Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. using System.Runtime.CompilerServices; @@ -10,19 +10,8 @@ namespace Xunit.Sdk; /// public class CocoaFactDiscoverer : FactDiscoverer { - private readonly IMessageSink diagnosticMessageSink; - - /// - /// Initializes a new instance of the class. - /// - /// The diagnostic message sink. - public CocoaFactDiscoverer(IMessageSink diagnosticMessageSink) - : base(diagnosticMessageSink) - { - this.diagnosticMessageSink = diagnosticMessageSink; - } - - protected override IXunitTestCase CreateTestCase(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute) + /// + protected override IXunitTestCase CreateTestCase(ITestFrameworkDiscoveryOptions discoveryOptions, IXunitTestMethod testMethod, IFactAttribute factAttribute) { if (testMethod is null) { @@ -32,10 +21,10 @@ protected override IXunitTestCase CreateTestCase(ITestFrameworkDiscoveryOptions if (testMethod.Method.ReturnType.Name == "System.Void" && testMethod.Method.GetCustomAttributes(typeof(AsyncStateMachineAttribute)).Any()) { - return new ExecutionErrorTestCase(this.diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), TestMethodDisplayOptions.None, testMethod, "Async void methods are not supported."); + return new ExecutionErrorTestCase(discoveryOptions.MethodDisplayOrDefault(), TestMethodDisplayOptions.None, testMethod, "Async void methods are not supported."); } UISettingsAttribute settings = UIFactDiscoverer.GetSettings(testMethod); - return new UITestCase(UITestCase.SyncContextType.Cocoa, this.diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod, testMethodArguments: null, settings); + return new UITestCase(UITestCase.SyncContextType.Cocoa, discoveryOptions.MethodDisplayOrDefault(), testMethod, testMethodArguments: null, settings); } } diff --git a/src/Xunit.StaFact/Sdk.Mac/CocoaTheoryDiscoverer.cs b/src/Xunit.StaFact/Sdk.Mac/CocoaTheoryDiscoverer.cs index 6f48e746..a6a5b7ce 100644 --- a/src/Xunit.StaFact/Sdk.Mac/CocoaTheoryDiscoverer.cs +++ b/src/Xunit.StaFact/Sdk.Mac/CocoaTheoryDiscoverer.cs @@ -1,4 +1,4 @@ -// Copyright (c) Andrew Arnott. All rights reserved. +// Copyright (c) Andrew Arnott. All rights reserved. // Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. namespace Xunit.Sdk; @@ -8,24 +8,17 @@ namespace Xunit.Sdk; /// public class CocoaTheoryDiscoverer : TheoryDiscoverer { - /// - /// Initializes a new instance of the class. - /// - /// The diagnostic message sink. - public CocoaTheoryDiscoverer(IMessageSink diagnosticMessageSink) - : base(diagnosticMessageSink) - { - } - - protected override IEnumerable CreateTestCasesForDataRow(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo theoryAttribute, object[] dataRow) + /// + protected override ValueTask> CreateTestCasesForDataRow(ITestFrameworkDiscoveryOptions discoveryOptions, IXunitTestMethod testMethod, ITheoryAttribute theoryAttribute, ITheoryDataRow dataRow, object?[] testMethodArguments) { UISettingsAttribute settings = UIFactDiscoverer.GetSettings(testMethod); - yield return new UITestCase(UITestCase.SyncContextType.Cocoa, this.DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod, dataRow, settings); + return new([new UITestCase(UITestCase.SyncContextType.Cocoa, discoveryOptions.MethodDisplayOrDefault(), testMethod, dataRow, settings)]); } - protected override IEnumerable CreateTestCasesForTheory(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo theoryAttribute) + /// + protected override ValueTask> CreateTestCasesForTheory(ITestFrameworkDiscoveryOptions discoveryOptions, IXunitTestMethod testMethod, ITheoryAttribute theoryAttribute) { UISettingsAttribute settings = UIFactDiscoverer.GetSettings(testMethod); - yield return new UITheoryTestCase(UITestCase.SyncContextType.Cocoa, this.DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), TestMethodDisplayOptions.None, testMethod, settings); + return new([new UITheoryTestCase(UITestCase.SyncContextType.Cocoa, discoveryOptions.MethodDisplayOrDefault(), TestMethodDisplayOptions.None, testMethod, settings)]); } } diff --git a/src/Xunit.StaFact/Sdk.WindowsDesktop/WinFormsFactDiscoverer.cs b/src/Xunit.StaFact/Sdk.WindowsDesktop/WinFormsFactDiscoverer.cs index 3a503ca1..2c4f4037 100644 --- a/src/Xunit.StaFact/Sdk.WindowsDesktop/WinFormsFactDiscoverer.cs +++ b/src/Xunit.StaFact/Sdk.WindowsDesktop/WinFormsFactDiscoverer.cs @@ -1,4 +1,4 @@ -// Copyright (c) Andrew Arnott. All rights reserved. +// Copyright (c) Andrew Arnott. All rights reserved. // Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. using System.Runtime.CompilerServices; @@ -11,19 +11,8 @@ namespace Xunit.Sdk; /// public class WinFormsFactDiscoverer : FactDiscoverer { - private readonly IMessageSink diagnosticMessageSink; - - /// - /// Initializes a new instance of the class. - /// - /// The diagnostic message sink. - public WinFormsFactDiscoverer(IMessageSink diagnosticMessageSink) - : base(diagnosticMessageSink) - { - this.diagnosticMessageSink = diagnosticMessageSink; - } - - protected override IXunitTestCase CreateTestCase(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute) + /// + protected override IXunitTestCase CreateTestCase(ITestFrameworkDiscoveryOptions discoveryOptions, IXunitTestMethod testMethod, IFactAttribute factAttribute) { if (testMethod is null) { @@ -33,12 +22,12 @@ protected override IXunitTestCase CreateTestCase(ITestFrameworkDiscoveryOptions if (testMethod.Method.ReturnType.Name == "System.Void" && testMethod.Method.GetCustomAttributes(typeof(AsyncStateMachineAttribute)).Any()) { - return new ExecutionErrorTestCase(this.diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), TestMethodDisplayOptions.None, testMethod, "Async void methods are not supported."); + return new ExecutionErrorTestCase(discoveryOptions.MethodDisplayOrDefault(), TestMethodDisplayOptions.None, testMethod, "Async void methods are not supported."); } UISettingsAttribute settings = UIFactDiscoverer.GetSettings(testMethod); return RuntimeInformation.IsOSPlatform(OSPlatform.Windows) - ? new UITestCase(UITestCase.SyncContextType.WinForms, this.diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod, testMethodArguments: null, settings) - : new XunitSkippedDataRowTestCase(this.diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, "WinForms only exists on Windows."); + ? new UITestCase(UITestCase.SyncContextType.WinForms, discoveryOptions.MethodDisplayOrDefault(), testMethod, testMethodArguments: null, settings) + : new XunitSkippedDataRowTestCase(discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, "WinForms only exists on Windows."); } } diff --git a/src/Xunit.StaFact/Sdk.WindowsDesktop/WinFormsTheoryDiscoverer.cs b/src/Xunit.StaFact/Sdk.WindowsDesktop/WinFormsTheoryDiscoverer.cs index c96240fb..6ddf9f44 100644 --- a/src/Xunit.StaFact/Sdk.WindowsDesktop/WinFormsTheoryDiscoverer.cs +++ b/src/Xunit.StaFact/Sdk.WindowsDesktop/WinFormsTheoryDiscoverer.cs @@ -1,4 +1,4 @@ -// Copyright (c) Andrew Arnott. All rights reserved. +// Copyright (c) Andrew Arnott. All rights reserved. // Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. using System.Runtime.InteropServices; @@ -10,28 +10,23 @@ namespace Xunit.Sdk; /// public class WinFormsTheoryDiscoverer : TheoryDiscoverer { - /// - /// Initializes a new instance of the class. - /// - /// The diagnostic message sink. - public WinFormsTheoryDiscoverer(IMessageSink diagnosticMessageSink) - : base(diagnosticMessageSink) - { - } - - protected override IEnumerable CreateTestCasesForDataRow(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo theoryAttribute, object[] dataRow) + /// + protected override ValueTask> CreateTestCasesForDataRow(ITestFrameworkDiscoveryOptions discoveryOptions, IXunitTestMethod testMethod, ITheoryAttribute theoryAttribute, ITheoryDataRow dataRow, object?[] testMethodArguments) { UISettingsAttribute settings = UIFactDiscoverer.GetSettings(testMethod); - yield return RuntimeInformation.IsOSPlatform(OSPlatform.Windows) - ? new UITestCase(UITestCase.SyncContextType.WinForms, this.DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod, dataRow, settings) - : new XunitSkippedDataRowTestCase(this.DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, "WinForms only exists on Windows."); + IXunitTestCase testCase = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) + ? new UITestCase(UITestCase.SyncContextType.WinForms, discoveryOptions.MethodDisplayOrDefault(), testMethod, dataRow, settings) + : new XunitSkippedDataRowTestCase(discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, "WinForms only exists on Windows."); + return new([testCase]); } - protected override IEnumerable CreateTestCasesForTheory(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo theoryAttribute) + /// + protected override ValueTask> CreateTestCasesForTheory(ITestFrameworkDiscoveryOptions discoveryOptions, IXunitTestMethod testMethod, ITheoryAttribute theoryAttribute) { UISettingsAttribute settings = UIFactDiscoverer.GetSettings(testMethod); - yield return RuntimeInformation.IsOSPlatform(OSPlatform.Windows) - ? new UITheoryTestCase(UITestCase.SyncContextType.WinForms, this.DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), TestMethodDisplayOptions.None, testMethod, settings) - : new XunitSkippedDataRowTestCase(this.DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, "WinForms only exists on Windows."); + IXunitTestCase testCase = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) + ? new UITheoryTestCase(UITestCase.SyncContextType.WinForms, discoveryOptions.MethodDisplayOrDefault(), TestMethodDisplayOptions.None, testMethod, settings) + : new XunitSkippedDataRowTestCase(discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, "WinForms only exists on Windows."); + return new([testCase]); } } diff --git a/src/Xunit.StaFact/Sdk.WindowsDesktop/WpfFactDiscoverer.cs b/src/Xunit.StaFact/Sdk.WindowsDesktop/WpfFactDiscoverer.cs index e117c19c..0f524cb8 100644 --- a/src/Xunit.StaFact/Sdk.WindowsDesktop/WpfFactDiscoverer.cs +++ b/src/Xunit.StaFact/Sdk.WindowsDesktop/WpfFactDiscoverer.cs @@ -1,4 +1,4 @@ -// Copyright (c) Andrew Arnott. All rights reserved. +// Copyright (c) Andrew Arnott. All rights reserved. // Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. using System.Runtime.CompilerServices; @@ -11,19 +11,8 @@ namespace Xunit.Sdk; /// public class WpfFactDiscoverer : FactDiscoverer { - private readonly IMessageSink diagnosticMessageSink; - - /// - /// Initializes a new instance of the class. - /// - /// The diagnostic message sink. - public WpfFactDiscoverer(IMessageSink diagnosticMessageSink) - : base(diagnosticMessageSink) - { - this.diagnosticMessageSink = diagnosticMessageSink; - } - - protected override IXunitTestCase CreateTestCase(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute) + /// + protected override IXunitTestCase CreateTestCase(ITestFrameworkDiscoveryOptions discoveryOptions, IXunitTestMethod testMethod, IFactAttribute factAttribute) { if (testMethod is null) { @@ -33,12 +22,12 @@ protected override IXunitTestCase CreateTestCase(ITestFrameworkDiscoveryOptions if (testMethod.Method.ReturnType.Name == "System.Void" && testMethod.Method.GetCustomAttributes(typeof(AsyncStateMachineAttribute)).Any()) { - return new ExecutionErrorTestCase(this.diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), TestMethodDisplayOptions.None, testMethod, "Async void methods are not supported."); + return new ExecutionErrorTestCase(discoveryOptions.MethodDisplayOrDefault(), TestMethodDisplayOptions.None, testMethod, "Async void methods are not supported."); } UISettingsAttribute settings = UIFactDiscoverer.GetSettings(testMethod); return RuntimeInformation.IsOSPlatform(OSPlatform.Windows) - ? new UITestCase(UITestCase.SyncContextType.WPF, this.diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod, testMethodArguments: null, settings) - : new XunitSkippedDataRowTestCase(this.diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, "WPF only exists on Windows."); + ? new UITestCase(UITestCase.SyncContextType.WPF, discoveryOptions.MethodDisplayOrDefault(), testMethod, testMethodArguments: null, settings) + : new XunitSkippedDataRowTestCase(discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, "WPF only exists on Windows."); } } diff --git a/src/Xunit.StaFact/Sdk.WindowsDesktop/WpfTheoryDiscoverer.cs b/src/Xunit.StaFact/Sdk.WindowsDesktop/WpfTheoryDiscoverer.cs index e8bba685..e7bbdf59 100644 --- a/src/Xunit.StaFact/Sdk.WindowsDesktop/WpfTheoryDiscoverer.cs +++ b/src/Xunit.StaFact/Sdk.WindowsDesktop/WpfTheoryDiscoverer.cs @@ -1,4 +1,4 @@ -// Copyright (c) Andrew Arnott. All rights reserved. +// Copyright (c) Andrew Arnott. All rights reserved. // Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. using System.Runtime.InteropServices; @@ -10,28 +10,23 @@ namespace Xunit.Sdk; /// public class WpfTheoryDiscoverer : TheoryDiscoverer { - /// - /// Initializes a new instance of the class. - /// - /// The diagnostic message sink. - public WpfTheoryDiscoverer(IMessageSink diagnosticMessageSink) - : base(diagnosticMessageSink) - { - } - - protected override IEnumerable CreateTestCasesForDataRow(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo theoryAttribute, object[] dataRow) + /// + protected override ValueTask> CreateTestCasesForDataRow(ITestFrameworkDiscoveryOptions discoveryOptions, IXunitTestMethod testMethod, ITheoryAttribute theoryAttribute, ITheoryDataRow dataRow, object?[] testMethodArguments) { UISettingsAttribute settings = UIFactDiscoverer.GetSettings(testMethod); - yield return RuntimeInformation.IsOSPlatform(OSPlatform.Windows) - ? new UITestCase(UITestCase.SyncContextType.WPF, this.DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod, dataRow, settings) - : new XunitSkippedDataRowTestCase(this.DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, "WPF only exists on Windows."); + IXunitTestCase testCase = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) + ? new UITestCase(UITestCase.SyncContextType.WPF, discoveryOptions.MethodDisplayOrDefault(), testMethod, dataRow, settings) + : new XunitSkippedDataRowTestCase(discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, "WPF only exists on Windows."); + return new([testCase]); } - protected override IEnumerable CreateTestCasesForTheory(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo theoryAttribute) + /// + protected override ValueTask> CreateTestCasesForTheory(ITestFrameworkDiscoveryOptions discoveryOptions, IXunitTestMethod testMethod, ITheoryAttribute theoryAttribute) { UISettingsAttribute settings = UIFactDiscoverer.GetSettings(testMethod); - yield return RuntimeInformation.IsOSPlatform(OSPlatform.Windows) - ? new UITheoryTestCase(UITestCase.SyncContextType.WPF, this.DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), TestMethodDisplayOptions.None, testMethod, settings) - : new XunitSkippedDataRowTestCase(this.DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, "WPF only exists on Windows."); + IXunitTestCase testCase = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) + ? new UITheoryTestCase(UITestCase.SyncContextType.WPF, discoveryOptions.MethodDisplayOrDefault(), TestMethodDisplayOptions.None, testMethod, settings) + : new XunitSkippedDataRowTestCase(discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, "WPF only exists on Windows."); + return new([testCase]); } } diff --git a/src/Xunit.StaFact/Sdk/StaFactDiscoverer.cs b/src/Xunit.StaFact/Sdk/StaFactDiscoverer.cs index 46315e14..e285d4b6 100644 --- a/src/Xunit.StaFact/Sdk/StaFactDiscoverer.cs +++ b/src/Xunit.StaFact/Sdk/StaFactDiscoverer.cs @@ -1,4 +1,4 @@ -// Copyright (c) Andrew Arnott. All rights reserved. +// Copyright (c) Andrew Arnott. All rights reserved. // Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. using System.Runtime.CompilerServices; @@ -11,15 +11,8 @@ namespace Xunit.Sdk; /// public class StaFactDiscoverer : FactDiscoverer { - /// - /// Initializes a new instance of the class. - /// - public StaFactDiscoverer() - { - } - /// - protected override IXunitTestCase CreateTestCase(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute) + protected override IXunitTestCase CreateTestCase(ITestFrameworkDiscoveryOptions discoveryOptions, IXunitTestMethod testMethod, IFactAttribute factAttribute) { if (testMethod is null) { @@ -28,7 +21,7 @@ protected override IXunitTestCase CreateTestCase(ITestFrameworkDiscoveryOptions UISettingsAttribute settings = UIFactDiscoverer.GetSettings(testMethod); return RuntimeInformation.IsOSPlatform(OSPlatform.Windows) - ? new UITestCase(UITestCase.SyncContextType.None, this.diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod, testMethodArguments: null, settings) - : new XunitSkippedDataRowTestCase(this.diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, "STA threads only exist on Windows."); + ? new UITestCase(UITestCase.SyncContextType.None, discoveryOptions.MethodDisplayOrDefault(), testMethod, testMethodArguments: null, settings) + : new XunitSkippedDataRowTestCase(discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, "STA threads only exist on Windows."); } } diff --git a/src/Xunit.StaFact/Sdk/StaTheoryDiscoverer.cs b/src/Xunit.StaFact/Sdk/StaTheoryDiscoverer.cs index 7c8cf2cf..59f59624 100644 --- a/src/Xunit.StaFact/Sdk/StaTheoryDiscoverer.cs +++ b/src/Xunit.StaFact/Sdk/StaTheoryDiscoverer.cs @@ -1,4 +1,4 @@ -// Copyright (c) Andrew Arnott. All rights reserved. +// Copyright (c) Andrew Arnott. All rights reserved. // Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. using System.Runtime.CompilerServices; @@ -11,14 +11,8 @@ namespace Xunit.Sdk; /// public class StaTheoryDiscoverer : TheoryDiscoverer { - /// - /// Initializes a new instance of the class. - /// - public StaTheoryDiscoverer() - { - } - - protected override IEnumerable CreateTestCasesForDataRow(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo theoryAttribute, object[] dataRow) + /// + protected override ValueTask> CreateTestCasesForDataRow(ITestFrameworkDiscoveryOptions discoveryOptions, IXunitTestMethod testMethod, ITheoryAttribute theoryAttribute, ITheoryDataRow dataRow, object?[] testMethodArguments) { if (testMethod is null) { @@ -27,11 +21,12 @@ protected override IEnumerable CreateTestCasesForDataRow(ITestFr UISettingsAttribute settings = UIFactDiscoverer.GetSettings(testMethod); yield return RuntimeInformation.IsOSPlatform(OSPlatform.Windows) - ? new UITestCase(UITestCase.SyncContextType.None, this.DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod, dataRow, settings) - : new XunitSkippedDataRowTestCase(this.DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, "STA threads only exist on Windows."); + ? new UITestCase(UITestCase.SyncContextType.None, discoveryOptions.MethodDisplayOrDefault(), testMethod, dataRow, settings) + : new XunitSkippedDataRowTestCase(discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, "STA threads only exist on Windows."); } - protected override IEnumerable CreateTestCasesForTheory(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo theoryAttribute) + /// + protected override ValueTask> CreateTestCasesForTheory(ITestFrameworkDiscoveryOptions discoveryOptions, IXunitTestMethod testMethod, ITheoryAttribute theoryAttribute) { if (testMethod is null) { @@ -40,7 +35,7 @@ protected override IEnumerable CreateTestCasesForTheory(ITestFra UISettingsAttribute settings = UIFactDiscoverer.GetSettings(testMethod); yield return RuntimeInformation.IsOSPlatform(OSPlatform.Windows) - ? new UITheoryTestCase(UITestCase.SyncContextType.None, this.DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), TestMethodDisplayOptions.None, testMethod, settings) - : new XunitSkippedDataRowTestCase(this.DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, "STA threads only exist on Windows."); + ? new UITheoryTestCase(UITestCase.SyncContextType.None, discoveryOptions.MethodDisplayOrDefault(), TestMethodDisplayOptions.None, testMethod, settings) + : new XunitSkippedDataRowTestCase(discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, "STA threads only exist on Windows."); } } diff --git a/src/Xunit.StaFact/Sdk/UIFactDiscoverer.cs b/src/Xunit.StaFact/Sdk/UIFactDiscoverer.cs index c5a9f59b..5a2208e0 100644 --- a/src/Xunit.StaFact/Sdk/UIFactDiscoverer.cs +++ b/src/Xunit.StaFact/Sdk/UIFactDiscoverer.cs @@ -1,4 +1,4 @@ -// Copyright (c) Andrew Arnott. All rights reserved. +// Copyright (c) Andrew Arnott. All rights reserved. // Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. namespace Xunit.Sdk; @@ -8,39 +8,25 @@ namespace Xunit.Sdk; /// public class UIFactDiscoverer : FactDiscoverer { - private readonly IMessageSink diagnosticMessageSink; - - /// - /// Initializes a new instance of the class. - /// - /// The diagnostic message sink. - public UIFactDiscoverer(IMessageSink diagnosticMessageSink) - : base(diagnosticMessageSink) - { - this.diagnosticMessageSink = diagnosticMessageSink; - } - - internal static UISettingsAttribute GetSettings(ITestMethod testMethod) + internal static UISettingsAttribute GetSettings(IXunitTestMethod testMethod) { // Initialize with defaults. UISettingsAttribute settings = UISettingsAttribute.Default; // Enumerate through each attribute (each progressively overriding the previous) and apply any explicitly set values to the attribute we'll return. - foreach (IAttributeInfo settingsAttribute in GetSettingsAttributes(testMethod)) + foreach (UISettingsAttribute settingsAttribute in GetSettingsAttributes(testMethod)) { - if (settingsAttribute.GetNamedArgument(nameof(UISettingsAttribute.MaxAttempts)) is int maxAttempts) - { - settings.MaxAttempts = maxAttempts; - } + settings.MaxAttempts = settingsAttribute.MaxAttempts; } return settings; } - protected override IXunitTestCase CreateTestCase(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute) + /// + protected override IXunitTestCase CreateTestCase(ITestFrameworkDiscoveryOptions discoveryOptions, IXunitTestMethod testMethod, IFactAttribute factAttribute) { UISettingsAttribute settings = GetSettings(testMethod); - return new UITestCase(UITestCase.SyncContextType.Portable, this.diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod, testMethodArguments: null, settings); + return new UITestCase(UITestCase.SyncContextType.Portable, discoveryOptions.MethodDisplayOrDefault(), testMethod, testMethodArguments: null, settings); } private static IEnumerable GetSettingsAttributes(IXunitTestMethod testMethod) diff --git a/src/Xunit.StaFact/Sdk/UITheoryDiscoverer.cs b/src/Xunit.StaFact/Sdk/UITheoryDiscoverer.cs index 510ef1c0..d0cab559 100644 --- a/src/Xunit.StaFact/Sdk/UITheoryDiscoverer.cs +++ b/src/Xunit.StaFact/Sdk/UITheoryDiscoverer.cs @@ -1,4 +1,4 @@ -// Copyright (c) Andrew Arnott. All rights reserved. +// Copyright (c) Andrew Arnott. All rights reserved. // Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. namespace Xunit.Sdk; @@ -8,24 +8,19 @@ namespace Xunit.Sdk; /// public class UITheoryDiscoverer : TheoryDiscoverer { - /// - /// Initializes a new instance of the class. - /// - /// The diagnostic message sink. - public UITheoryDiscoverer(IMessageSink diagnosticMessageSink) - : base(diagnosticMessageSink) - { - } - - protected override IEnumerable CreateTestCasesForDataRow(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo theoryAttribute, object[] dataRow) + /// + protected override ValueTask> CreateTestCasesForDataRow(ITestFrameworkDiscoveryOptions discoveryOptions, IXunitTestMethod testMethod, ITheoryAttribute theoryAttribute, ITheoryDataRow dataRow, object?[] testMethodArguments) { UISettingsAttribute settings = UIFactDiscoverer.GetSettings(testMethod); - yield return new UITestCase(UITestCase.SyncContextType.Portable, this.DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod, dataRow, settings); + IXunitTestCase testCase = new UITestCase(UITestCase.SyncContextType.Portable, discoveryOptions.MethodDisplayOrDefault(), testMethod, dataRow, settings); + return new([testCase]); } - protected override IEnumerable CreateTestCasesForTheory(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo theoryAttribute) + /// + protected override ValueTask> CreateTestCasesForTheory(ITestFrameworkDiscoveryOptions discoveryOptions, IXunitTestMethod testMethod, ITheoryAttribute theoryAttribute) { UISettingsAttribute settings = UIFactDiscoverer.GetSettings(testMethod); - yield return new UITheoryTestCase(UITestCase.SyncContextType.Portable, this.DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), TestMethodDisplayOptions.None, testMethod, settings); + IXunitTestCase testCase = new UITheoryTestCase(UITestCase.SyncContextType.Portable, discoveryOptions.MethodDisplayOrDefault(), TestMethodDisplayOptions.None, testMethod, settings); + return new([testCase]); } } diff --git a/src/Xunit.StaFact/Sdk/UITheoryTestCase.cs b/src/Xunit.StaFact/Sdk/UITheoryTestCase.cs index 0468c5f7..b3f39c3b 100644 --- a/src/Xunit.StaFact/Sdk/UITheoryTestCase.cs +++ b/src/Xunit.StaFact/Sdk/UITheoryTestCase.cs @@ -1,4 +1,4 @@ -// Copyright (c) Andrew Arnott. All rights reserved. +// Copyright (c) Andrew Arnott. All rights reserved. // Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. using System.ComponentModel; @@ -13,8 +13,8 @@ public UITheoryTestCase() { } - internal UITheoryTestCase(UITestCase.SyncContextType synchronizationContextType, IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, ITestMethod testMethod, UISettingsAttribute settings) - : base(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod) + internal UITheoryTestCase(UITestCase.SyncContextType synchronizationContextType, TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, ITestMethod testMethod, UISettingsAttribute settings) + : base(defaultMethodDisplay, defaultMethodDisplayOptions, testMethod) { this.Settings = settings; settings.ApplyTraits(this); diff --git a/src/Xunit.StaFact/UISettingsAttribute.cs b/src/Xunit.StaFact/UISettingsAttribute.cs index c746801d..93f7dd20 100644 --- a/src/Xunit.StaFact/UISettingsAttribute.cs +++ b/src/Xunit.StaFact/UISettingsAttribute.cs @@ -1,8 +1,6 @@ -// Copyright (c) Andrew Arnott. All rights reserved. +// Copyright (c) Andrew Arnott. All rights reserved. // Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. -using Xunit.Sdk; - namespace Xunit; [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = false, Inherited = true)] diff --git a/src/Xunit.StaFact/Usings.cs b/src/Xunit.StaFact/Usings.cs index 28d713c0..4e754791 100644 --- a/src/Xunit.StaFact/Usings.cs +++ b/src/Xunit.StaFact/Usings.cs @@ -1,4 +1,5 @@ -// Copyright (c) Andrew Arnott. All rights reserved. +// Copyright (c) Andrew Arnott. All rights reserved. // Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. +global using Xunit; global using Xunit.v3; From 3f6b9cbd2a674c9bd003d0e23a8c98fe133550bf Mon Sep 17 00:00:00 2001 From: reduckted Date: Wed, 8 Jan 2025 21:20:18 +1000 Subject: [PATCH 07/27] Updated test case creation. --- .../Sdk.Mac/CocoaFactDiscoverer.cs | 16 +-- .../Sdk.Mac/CocoaTheoryDiscoverer.cs | 19 +++- src/Xunit.StaFact/Sdk.Mac/CocoaUtilities.cs | 24 +++++ .../WinFormsFactDiscoverer.cs | 24 ++--- .../WinFormsTheoryDiscoverer.cs | 22 +++-- .../Sdk.WindowsDesktop/WinFormsUtilities.cs | 26 +++++ .../Sdk.WindowsDesktop/WpfFactDiscoverer.cs | 22 ++--- .../Sdk.WindowsDesktop/WpfTheoryDiscoverer.cs | 22 +++-- .../Sdk.WindowsDesktop/WpfUtilities.cs | 26 +++++ src/Xunit.StaFact/Sdk/SkippedTestCase.cs | 47 +++++++++ src/Xunit.StaFact/Sdk/StaFactDiscoverer.cs | 13 +-- src/Xunit.StaFact/Sdk/StaTheoryDiscoverer.cs | 35 +++---- src/Xunit.StaFact/Sdk/StaUtilities.cs | 26 +++++ src/Xunit.StaFact/Sdk/TestCaseKind.cs | 11 +++ .../Sdk/UIDelayEnumeratedTestCase.cs | 81 +++++++++++++++ src/Xunit.StaFact/Sdk/UIFactDiscoverer.cs | 30 +----- src/Xunit.StaFact/Sdk/UITestCase.cs | 25 +++-- src/Xunit.StaFact/Sdk/UITheoryDiscoverer.cs | 16 ++- src/Xunit.StaFact/Sdk/UITheoryTestCase.cs | 62 ------------ src/Xunit.StaFact/Sdk/UIUtilities.cs | 24 +++++ src/Xunit.StaFact/Sdk/Utilities.cs | 98 ++++++++++++++++++- 21 files changed, 461 insertions(+), 208 deletions(-) create mode 100644 src/Xunit.StaFact/Sdk.Mac/CocoaUtilities.cs create mode 100644 src/Xunit.StaFact/Sdk.WindowsDesktop/WinFormsUtilities.cs create mode 100644 src/Xunit.StaFact/Sdk.WindowsDesktop/WpfUtilities.cs create mode 100644 src/Xunit.StaFact/Sdk/SkippedTestCase.cs create mode 100644 src/Xunit.StaFact/Sdk/StaUtilities.cs create mode 100644 src/Xunit.StaFact/Sdk/TestCaseKind.cs create mode 100644 src/Xunit.StaFact/Sdk/UIDelayEnumeratedTestCase.cs delete mode 100644 src/Xunit.StaFact/Sdk/UITheoryTestCase.cs create mode 100644 src/Xunit.StaFact/Sdk/UIUtilities.cs diff --git a/src/Xunit.StaFact/Sdk.Mac/CocoaFactDiscoverer.cs b/src/Xunit.StaFact/Sdk.Mac/CocoaFactDiscoverer.cs index 43e85c19..6f5f83ec 100644 --- a/src/Xunit.StaFact/Sdk.Mac/CocoaFactDiscoverer.cs +++ b/src/Xunit.StaFact/Sdk.Mac/CocoaFactDiscoverer.cs @@ -1,8 +1,6 @@ // Copyright (c) Andrew Arnott. All rights reserved. // Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. -using System.Runtime.CompilerServices; - namespace Xunit.Sdk; /// @@ -13,18 +11,6 @@ public class CocoaFactDiscoverer : FactDiscoverer /// protected override IXunitTestCase CreateTestCase(ITestFrameworkDiscoveryOptions discoveryOptions, IXunitTestMethod testMethod, IFactAttribute factAttribute) { - if (testMethod is null) - { - throw new ArgumentNullException(nameof(testMethod)); - } - - if (testMethod.Method.ReturnType.Name == "System.Void" && - testMethod.Method.GetCustomAttributes(typeof(AsyncStateMachineAttribute)).Any()) - { - return new ExecutionErrorTestCase(discoveryOptions.MethodDisplayOrDefault(), TestMethodDisplayOptions.None, testMethod, "Async void methods are not supported."); - } - - UISettingsAttribute settings = UIFactDiscoverer.GetSettings(testMethod); - return new UITestCase(UITestCase.SyncContextType.Cocoa, discoveryOptions.MethodDisplayOrDefault(), testMethod, testMethodArguments: null, settings); + return CocoaUtilities.CreateTestCase(TestCaseKind.Fact, discoveryOptions, testMethod, factAttribute, null); } } diff --git a/src/Xunit.StaFact/Sdk.Mac/CocoaTheoryDiscoverer.cs b/src/Xunit.StaFact/Sdk.Mac/CocoaTheoryDiscoverer.cs index a6a5b7ce..8e9c86fd 100644 --- a/src/Xunit.StaFact/Sdk.Mac/CocoaTheoryDiscoverer.cs +++ b/src/Xunit.StaFact/Sdk.Mac/CocoaTheoryDiscoverer.cs @@ -1,6 +1,7 @@ // Copyright (c) Andrew Arnott. All rights reserved. // Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. + namespace Xunit.Sdk; /// @@ -11,14 +12,24 @@ public class CocoaTheoryDiscoverer : TheoryDiscoverer /// protected override ValueTask> CreateTestCasesForDataRow(ITestFrameworkDiscoveryOptions discoveryOptions, IXunitTestMethod testMethod, ITheoryAttribute theoryAttribute, ITheoryDataRow dataRow, object?[] testMethodArguments) { - UISettingsAttribute settings = UIFactDiscoverer.GetSettings(testMethod); - return new([new UITestCase(UITestCase.SyncContextType.Cocoa, discoveryOptions.MethodDisplayOrDefault(), testMethod, dataRow, settings)]); + IXunitTestCase testCase = CocoaUtilities.CreateTestCase( + TestCaseKind.DataRow, + discoveryOptions, + testMethod, + theoryAttribute, + testMethodArguments); + return new([testCase]); } /// protected override ValueTask> CreateTestCasesForTheory(ITestFrameworkDiscoveryOptions discoveryOptions, IXunitTestMethod testMethod, ITheoryAttribute theoryAttribute) { - UISettingsAttribute settings = UIFactDiscoverer.GetSettings(testMethod); - return new([new UITheoryTestCase(UITestCase.SyncContextType.Cocoa, discoveryOptions.MethodDisplayOrDefault(), TestMethodDisplayOptions.None, testMethod, settings)]); + IXunitTestCase testCase = CocoaUtilities.CreateTestCase( + TestCaseKind.DelayEnumerated, + discoveryOptions, + testMethod, + theoryAttribute, + null); + return new([testCase]); } } diff --git a/src/Xunit.StaFact/Sdk.Mac/CocoaUtilities.cs b/src/Xunit.StaFact/Sdk.Mac/CocoaUtilities.cs new file mode 100644 index 00000000..cd22d9e6 --- /dev/null +++ b/src/Xunit.StaFact/Sdk.Mac/CocoaUtilities.cs @@ -0,0 +1,24 @@ +// Copyright (c) Andrew Arnott. All rights reserved. +// Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. + +namespace Xunit.Sdk; + +internal static class CocoaUtilities +{ + internal static IXunitTestCase CreateTestCase( + TestCaseKind kind, + ITestFrameworkDiscoveryOptions discoveryOptions, + IXunitTestMethod testMethod, + IFactAttribute theoryAttribute, + object?[]? testMethodArguments) + { + return Utilities.CreateTestCase( + kind, + UITestCase.SyncContextType.Cocoa, + null, + discoveryOptions, + testMethod, + theoryAttribute, + testMethodArguments); + } +} diff --git a/src/Xunit.StaFact/Sdk.WindowsDesktop/WinFormsFactDiscoverer.cs b/src/Xunit.StaFact/Sdk.WindowsDesktop/WinFormsFactDiscoverer.cs index 2c4f4037..e8a0f59a 100644 --- a/src/Xunit.StaFact/Sdk.WindowsDesktop/WinFormsFactDiscoverer.cs +++ b/src/Xunit.StaFact/Sdk.WindowsDesktop/WinFormsFactDiscoverer.cs @@ -1,9 +1,6 @@ // Copyright (c) Andrew Arnott. All rights reserved. // Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - namespace Xunit.Sdk; /// @@ -14,20 +11,11 @@ public class WinFormsFactDiscoverer : FactDiscoverer /// protected override IXunitTestCase CreateTestCase(ITestFrameworkDiscoveryOptions discoveryOptions, IXunitTestMethod testMethod, IFactAttribute factAttribute) { - if (testMethod is null) - { - throw new ArgumentNullException(nameof(testMethod)); - } - - if (testMethod.Method.ReturnType.Name == "System.Void" && - testMethod.Method.GetCustomAttributes(typeof(AsyncStateMachineAttribute)).Any()) - { - return new ExecutionErrorTestCase(discoveryOptions.MethodDisplayOrDefault(), TestMethodDisplayOptions.None, testMethod, "Async void methods are not supported."); - } - - UISettingsAttribute settings = UIFactDiscoverer.GetSettings(testMethod); - return RuntimeInformation.IsOSPlatform(OSPlatform.Windows) - ? new UITestCase(UITestCase.SyncContextType.WinForms, discoveryOptions.MethodDisplayOrDefault(), testMethod, testMethodArguments: null, settings) - : new XunitSkippedDataRowTestCase(discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, "WinForms only exists on Windows."); + return WinFormsUtilities.CreateTestCase( + TestCaseKind.Fact, + discoveryOptions, + testMethod, + factAttribute, + null); } } diff --git a/src/Xunit.StaFact/Sdk.WindowsDesktop/WinFormsTheoryDiscoverer.cs b/src/Xunit.StaFact/Sdk.WindowsDesktop/WinFormsTheoryDiscoverer.cs index 6ddf9f44..f6f92cdc 100644 --- a/src/Xunit.StaFact/Sdk.WindowsDesktop/WinFormsTheoryDiscoverer.cs +++ b/src/Xunit.StaFact/Sdk.WindowsDesktop/WinFormsTheoryDiscoverer.cs @@ -1,8 +1,6 @@ // Copyright (c) Andrew Arnott. All rights reserved. // Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. -using System.Runtime.InteropServices; - namespace Xunit.Sdk; /// @@ -13,20 +11,24 @@ public class WinFormsTheoryDiscoverer : TheoryDiscoverer /// protected override ValueTask> CreateTestCasesForDataRow(ITestFrameworkDiscoveryOptions discoveryOptions, IXunitTestMethod testMethod, ITheoryAttribute theoryAttribute, ITheoryDataRow dataRow, object?[] testMethodArguments) { - UISettingsAttribute settings = UIFactDiscoverer.GetSettings(testMethod); - IXunitTestCase testCase = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) - ? new UITestCase(UITestCase.SyncContextType.WinForms, discoveryOptions.MethodDisplayOrDefault(), testMethod, dataRow, settings) - : new XunitSkippedDataRowTestCase(discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, "WinForms only exists on Windows."); + IXunitTestCase testCase = WinFormsUtilities.CreateTestCase( + TestCaseKind.DataRow, + discoveryOptions, + testMethod, + theoryAttribute, + testMethodArguments); return new([testCase]); } /// protected override ValueTask> CreateTestCasesForTheory(ITestFrameworkDiscoveryOptions discoveryOptions, IXunitTestMethod testMethod, ITheoryAttribute theoryAttribute) { - UISettingsAttribute settings = UIFactDiscoverer.GetSettings(testMethod); - IXunitTestCase testCase = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) - ? new UITheoryTestCase(UITestCase.SyncContextType.WinForms, discoveryOptions.MethodDisplayOrDefault(), TestMethodDisplayOptions.None, testMethod, settings) - : new XunitSkippedDataRowTestCase(discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, "WinForms only exists on Windows."); + IXunitTestCase testCase = WinFormsUtilities.CreateTestCase( + TestCaseKind.DelayEnumerated, + discoveryOptions, + testMethod, + theoryAttribute, + null); return new([testCase]); } } diff --git a/src/Xunit.StaFact/Sdk.WindowsDesktop/WinFormsUtilities.cs b/src/Xunit.StaFact/Sdk.WindowsDesktop/WinFormsUtilities.cs new file mode 100644 index 00000000..c3d06180 --- /dev/null +++ b/src/Xunit.StaFact/Sdk.WindowsDesktop/WinFormsUtilities.cs @@ -0,0 +1,26 @@ +// Copyright (c) Andrew Arnott. All rights reserved. +// Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. + +using System.Runtime.InteropServices; + +namespace Xunit.Sdk; + +internal static class WinFormsUtilities +{ + internal static IXunitTestCase CreateTestCase( + TestCaseKind kind, + ITestFrameworkDiscoveryOptions discoveryOptions, + IXunitTestMethod testMethod, + IFactAttribute theoryAttribute, + object?[]? testMethodArguments) + { + return Utilities.CreateTestCase( + kind, + UITestCase.SyncContextType.WinForms, + RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? null : "WinForms only exists on Windows.", + discoveryOptions, + testMethod, + theoryAttribute, + testMethodArguments); + } +} diff --git a/src/Xunit.StaFact/Sdk.WindowsDesktop/WpfFactDiscoverer.cs b/src/Xunit.StaFact/Sdk.WindowsDesktop/WpfFactDiscoverer.cs index 0f524cb8..e92ced4c 100644 --- a/src/Xunit.StaFact/Sdk.WindowsDesktop/WpfFactDiscoverer.cs +++ b/src/Xunit.StaFact/Sdk.WindowsDesktop/WpfFactDiscoverer.cs @@ -1,7 +1,6 @@ // Copyright (c) Andrew Arnott. All rights reserved. // Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; namespace Xunit.Sdk; @@ -14,20 +13,11 @@ public class WpfFactDiscoverer : FactDiscoverer /// protected override IXunitTestCase CreateTestCase(ITestFrameworkDiscoveryOptions discoveryOptions, IXunitTestMethod testMethod, IFactAttribute factAttribute) { - if (testMethod is null) - { - throw new ArgumentNullException(nameof(testMethod)); - } - - if (testMethod.Method.ReturnType.Name == "System.Void" && - testMethod.Method.GetCustomAttributes(typeof(AsyncStateMachineAttribute)).Any()) - { - return new ExecutionErrorTestCase(discoveryOptions.MethodDisplayOrDefault(), TestMethodDisplayOptions.None, testMethod, "Async void methods are not supported."); - } - - UISettingsAttribute settings = UIFactDiscoverer.GetSettings(testMethod); - return RuntimeInformation.IsOSPlatform(OSPlatform.Windows) - ? new UITestCase(UITestCase.SyncContextType.WPF, discoveryOptions.MethodDisplayOrDefault(), testMethod, testMethodArguments: null, settings) - : new XunitSkippedDataRowTestCase(discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, "WPF only exists on Windows."); + return WpfUtilities.CreateTestCase( + TestCaseKind.Fact, + discoveryOptions, + testMethod, + factAttribute, + null); } } diff --git a/src/Xunit.StaFact/Sdk.WindowsDesktop/WpfTheoryDiscoverer.cs b/src/Xunit.StaFact/Sdk.WindowsDesktop/WpfTheoryDiscoverer.cs index e7bbdf59..7e7fd1df 100644 --- a/src/Xunit.StaFact/Sdk.WindowsDesktop/WpfTheoryDiscoverer.cs +++ b/src/Xunit.StaFact/Sdk.WindowsDesktop/WpfTheoryDiscoverer.cs @@ -1,8 +1,6 @@ // Copyright (c) Andrew Arnott. All rights reserved. // Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. -using System.Runtime.InteropServices; - namespace Xunit.Sdk; /// @@ -13,20 +11,24 @@ public class WpfTheoryDiscoverer : TheoryDiscoverer /// protected override ValueTask> CreateTestCasesForDataRow(ITestFrameworkDiscoveryOptions discoveryOptions, IXunitTestMethod testMethod, ITheoryAttribute theoryAttribute, ITheoryDataRow dataRow, object?[] testMethodArguments) { - UISettingsAttribute settings = UIFactDiscoverer.GetSettings(testMethod); - IXunitTestCase testCase = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) - ? new UITestCase(UITestCase.SyncContextType.WPF, discoveryOptions.MethodDisplayOrDefault(), testMethod, dataRow, settings) - : new XunitSkippedDataRowTestCase(discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, "WPF only exists on Windows."); + IXunitTestCase testCase = WpfUtilities.CreateTestCase( + TestCaseKind.DataRow, + discoveryOptions, + testMethod, + theoryAttribute, + testMethodArguments); return new([testCase]); } /// protected override ValueTask> CreateTestCasesForTheory(ITestFrameworkDiscoveryOptions discoveryOptions, IXunitTestMethod testMethod, ITheoryAttribute theoryAttribute) { - UISettingsAttribute settings = UIFactDiscoverer.GetSettings(testMethod); - IXunitTestCase testCase = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) - ? new UITheoryTestCase(UITestCase.SyncContextType.WPF, discoveryOptions.MethodDisplayOrDefault(), TestMethodDisplayOptions.None, testMethod, settings) - : new XunitSkippedDataRowTestCase(discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, "WPF only exists on Windows."); + IXunitTestCase testCase = WpfUtilities.CreateTestCase( + TestCaseKind.DelayEnumerated, + discoveryOptions, + testMethod, + theoryAttribute, + null); return new([testCase]); } } diff --git a/src/Xunit.StaFact/Sdk.WindowsDesktop/WpfUtilities.cs b/src/Xunit.StaFact/Sdk.WindowsDesktop/WpfUtilities.cs new file mode 100644 index 00000000..d8e40eb3 --- /dev/null +++ b/src/Xunit.StaFact/Sdk.WindowsDesktop/WpfUtilities.cs @@ -0,0 +1,26 @@ +// Copyright (c) Andrew Arnott. All rights reserved. +// Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. + +using System.Runtime.InteropServices; + +namespace Xunit.Sdk; + +internal static class WpfUtilities +{ + internal static IXunitTestCase CreateTestCase( + TestCaseKind kind, + ITestFrameworkDiscoveryOptions discoveryOptions, + IXunitTestMethod testMethod, + IFactAttribute theoryAttribute, + object?[]? testMethodArguments) + { + return Utilities.CreateTestCase( + kind, + UITestCase.SyncContextType.WPF, + RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? null : "WPF only exists on Windows.", + discoveryOptions, + testMethod, + theoryAttribute, + testMethodArguments); + } +} diff --git a/src/Xunit.StaFact/Sdk/SkippedTestCase.cs b/src/Xunit.StaFact/Sdk/SkippedTestCase.cs new file mode 100644 index 00000000..15e033bf --- /dev/null +++ b/src/Xunit.StaFact/Sdk/SkippedTestCase.cs @@ -0,0 +1,47 @@ +using System.ComponentModel; + +namespace Xunit.Sdk; + +/// +/// Represents a test case that cannot run on the current platform. +/// +public class SkippedTestCase : XunitTestCase +{ + /// + /// Initializes a new instance of the class + /// for deserialization. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + [Obsolete("Called by the de-serializer; should only be called by deriving classes for de-serialization purposes")] + public SkippedTestCase() + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The test method this test case belongs to. + /// The display name for the test case. + /// The unique ID for the test case. + /// Indicates whether the test case was marked as explicit. + /// The reason the test is skipped. + /// The optional traits list. + /// The optional arguments for the test method. + /// The optional source file in where this test case originated. + /// The optional source line number where this test case originated. + /// The optional timeout for the test case (in milliseconds). + internal SkippedTestCase( + IXunitTestMethod testMethod, + string testCaseDisplayName, + string uniqueID, + bool @explicit, + string skipReason, + Dictionary>? traits = null, + object?[]? testMethodArguments = null, + string? sourceFilePath = null, + int? sourceLineNumber = null, + int? timeout = null) + : base(testMethod, testCaseDisplayName, uniqueID, @explicit, skipReason, null, null, null, traits, testMethodArguments, sourceFilePath, sourceLineNumber, timeout) + { + } +} diff --git a/src/Xunit.StaFact/Sdk/StaFactDiscoverer.cs b/src/Xunit.StaFact/Sdk/StaFactDiscoverer.cs index e285d4b6..5625ce57 100644 --- a/src/Xunit.StaFact/Sdk/StaFactDiscoverer.cs +++ b/src/Xunit.StaFact/Sdk/StaFactDiscoverer.cs @@ -1,9 +1,6 @@ // Copyright (c) Andrew Arnott. All rights reserved. // Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - namespace Xunit.Sdk; /// @@ -14,14 +11,6 @@ public class StaFactDiscoverer : FactDiscoverer /// protected override IXunitTestCase CreateTestCase(ITestFrameworkDiscoveryOptions discoveryOptions, IXunitTestMethod testMethod, IFactAttribute factAttribute) { - if (testMethod is null) - { - throw new ArgumentNullException(nameof(testMethod)); - } - - UISettingsAttribute settings = UIFactDiscoverer.GetSettings(testMethod); - return RuntimeInformation.IsOSPlatform(OSPlatform.Windows) - ? new UITestCase(UITestCase.SyncContextType.None, discoveryOptions.MethodDisplayOrDefault(), testMethod, testMethodArguments: null, settings) - : new XunitSkippedDataRowTestCase(discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, "STA threads only exist on Windows."); + return StaUtilities.CreateTestCase(TestCaseKind.Fact, discoveryOptions, testMethod, factAttribute, null); } } diff --git a/src/Xunit.StaFact/Sdk/StaTheoryDiscoverer.cs b/src/Xunit.StaFact/Sdk/StaTheoryDiscoverer.cs index 59f59624..49e19e2b 100644 --- a/src/Xunit.StaFact/Sdk/StaTheoryDiscoverer.cs +++ b/src/Xunit.StaFact/Sdk/StaTheoryDiscoverer.cs @@ -1,9 +1,6 @@ // Copyright (c) Andrew Arnott. All rights reserved. // Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - namespace Xunit.Sdk; /// @@ -14,28 +11,24 @@ public class StaTheoryDiscoverer : TheoryDiscoverer /// protected override ValueTask> CreateTestCasesForDataRow(ITestFrameworkDiscoveryOptions discoveryOptions, IXunitTestMethod testMethod, ITheoryAttribute theoryAttribute, ITheoryDataRow dataRow, object?[] testMethodArguments) { - if (testMethod is null) - { - throw new ArgumentNullException(nameof(testMethod)); - } - - UISettingsAttribute settings = UIFactDiscoverer.GetSettings(testMethod); - yield return RuntimeInformation.IsOSPlatform(OSPlatform.Windows) - ? new UITestCase(UITestCase.SyncContextType.None, discoveryOptions.MethodDisplayOrDefault(), testMethod, dataRow, settings) - : new XunitSkippedDataRowTestCase(discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, "STA threads only exist on Windows."); + IXunitTestCase testCase = StaUtilities.CreateTestCase( + TestCaseKind.DataRow, + discoveryOptions, + testMethod, + theoryAttribute, + testMethodArguments); + return new([testCase]); } /// protected override ValueTask> CreateTestCasesForTheory(ITestFrameworkDiscoveryOptions discoveryOptions, IXunitTestMethod testMethod, ITheoryAttribute theoryAttribute) { - if (testMethod is null) - { - throw new ArgumentNullException(nameof(testMethod)); - } - - UISettingsAttribute settings = UIFactDiscoverer.GetSettings(testMethod); - yield return RuntimeInformation.IsOSPlatform(OSPlatform.Windows) - ? new UITheoryTestCase(UITestCase.SyncContextType.None, discoveryOptions.MethodDisplayOrDefault(), TestMethodDisplayOptions.None, testMethod, settings) - : new XunitSkippedDataRowTestCase(discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, "STA threads only exist on Windows."); + IXunitTestCase testCase = StaUtilities.CreateTestCase( + TestCaseKind.DelayEnumerated, + discoveryOptions, + testMethod, + theoryAttribute, + null); + return new([testCase]); } } diff --git a/src/Xunit.StaFact/Sdk/StaUtilities.cs b/src/Xunit.StaFact/Sdk/StaUtilities.cs new file mode 100644 index 00000000..2be30c0b --- /dev/null +++ b/src/Xunit.StaFact/Sdk/StaUtilities.cs @@ -0,0 +1,26 @@ +// Copyright (c) Andrew Arnott. All rights reserved. +// Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. + +using System.Runtime.InteropServices; + +namespace Xunit.Sdk; + +internal static class StaUtilities +{ + internal static IXunitTestCase CreateTestCase( + TestCaseKind kind, + ITestFrameworkDiscoveryOptions discoveryOptions, + IXunitTestMethod testMethod, + IFactAttribute theoryAttribute, + object?[]? testMethodArguments) + { + return Utilities.CreateTestCase( + kind, + UITestCase.SyncContextType.None, + RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? null : "STA threads only exist on Windows.", + discoveryOptions, + testMethod, + theoryAttribute, + testMethodArguments); + } +} diff --git a/src/Xunit.StaFact/Sdk/TestCaseKind.cs b/src/Xunit.StaFact/Sdk/TestCaseKind.cs new file mode 100644 index 00000000..60843857 --- /dev/null +++ b/src/Xunit.StaFact/Sdk/TestCaseKind.cs @@ -0,0 +1,11 @@ +// Copyright (c) Andrew Arnott. All rights reserved. +// Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. + +namespace Xunit.Sdk; + +internal enum TestCaseKind +{ + Fact, + DataRow, + DelayEnumerated, +} diff --git a/src/Xunit.StaFact/Sdk/UIDelayEnumeratedTestCase.cs b/src/Xunit.StaFact/Sdk/UIDelayEnumeratedTestCase.cs new file mode 100644 index 00000000..e54250e3 --- /dev/null +++ b/src/Xunit.StaFact/Sdk/UIDelayEnumeratedTestCase.cs @@ -0,0 +1,81 @@ +// Copyright (c) Andrew Arnott. All rights reserved. +// Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. + +using System.ComponentModel; + +namespace Xunit.Sdk; + +public class UIDelayEnumeratedTestCase : XunitDelayEnumeratedTheoryTestCase +{ + [EditorBrowsable(EditorBrowsableState.Never)] + [Obsolete("Called by the de-serializer; should only be called by deriving classes for de-serialization purposes")] + public UIDelayEnumeratedTestCase() + { + } + + internal UIDelayEnumeratedTestCase( + UISettingsAttribute settings, + UITestCase.SyncContextType synchronizationContextType, + IXunitTestMethod testMethod, + string testCaseDisplayName, + string uniqueID, + bool @explicit, + bool skipTestWithoutData, + string? skipReason = null, + Type? skipType = null, + string? skipUnless = null, + string? skipWhen = null, + Dictionary>? traits = null, + string? sourceFilePath = null, + int? sourceLineNumber = null, + int? timeout = null) + : base(testMethod, testCaseDisplayName, uniqueID, @explicit, skipTestWithoutData, skipReason, skipType, skipUnless, skipWhen, traits, sourceFilePath, sourceLineNumber, timeout) + { + this.Settings = settings; + this.SynchronizationContextType = synchronizationContextType; + } + + internal UISettingsAttribute Settings { get; private set; } = UISettingsAttribute.Default; + + internal UITestCase.SyncContextType SynchronizationContextType { get; private set; } + + public Task RunAsync(IMessageSink diagnosticMessageSink, IMessageBus messageBus, object[] constructorArguments, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource) + { + using ThreadRental threadRental = await ThreadRental.CreateAsync(UITestCase.GetAdapter(this.SynchronizationContextType), this.TestMethod); + await threadRental.SynchronizationContext; + + // TODO: retry here if any test cases failed + return await new UITestCaseRunner(this, this.DisplayName, this.SkipReason, constructorArguments, diagnosticMessageSink, messageBus, aggregator, cancellationTokenSource, threadRental).RunAsync(); + } + + protected override void Deserialize(IXunitSerializationInfo data) + { + if (data is null) + { + throw new ArgumentNullException(nameof(data)); + } + + base.Deserialize(data); + + this.Settings = new UISettingsAttribute() { MaxAttempts = data.GetValue(nameof(UISettingsAttribute.MaxAttempts)) }; + + string? syncContextTypeName = data.GetValue("SyncContextType"); + if (syncContextTypeName is not null) + { + this.SynchronizationContextType = (UITestCase.SyncContextType)Enum.Parse(typeof(UITestCase.SyncContextType), syncContextTypeName); + } + } + + protected override void Serialize(IXunitSerializationInfo data) + { + if (data is null) + { + throw new ArgumentNullException(nameof(data)); + } + + base.Serialize(data); + + data.AddValue(nameof(UISettingsAttribute.MaxAttempts), this.Settings.MaxAttempts); + data.AddValue("SyncContextType", this.SynchronizationContextType.ToString()); + } +} diff --git a/src/Xunit.StaFact/Sdk/UIFactDiscoverer.cs b/src/Xunit.StaFact/Sdk/UIFactDiscoverer.cs index 5a2208e0..3e60d753 100644 --- a/src/Xunit.StaFact/Sdk/UIFactDiscoverer.cs +++ b/src/Xunit.StaFact/Sdk/UIFactDiscoverer.cs @@ -8,37 +8,9 @@ namespace Xunit.Sdk; /// public class UIFactDiscoverer : FactDiscoverer { - internal static UISettingsAttribute GetSettings(IXunitTestMethod testMethod) - { - // Initialize with defaults. - UISettingsAttribute settings = UISettingsAttribute.Default; - - // Enumerate through each attribute (each progressively overriding the previous) and apply any explicitly set values to the attribute we'll return. - foreach (UISettingsAttribute settingsAttribute in GetSettingsAttributes(testMethod)) - { - settings.MaxAttempts = settingsAttribute.MaxAttempts; - } - - return settings; - } - /// protected override IXunitTestCase CreateTestCase(ITestFrameworkDiscoveryOptions discoveryOptions, IXunitTestMethod testMethod, IFactAttribute factAttribute) { - UISettingsAttribute settings = GetSettings(testMethod); - return new UITestCase(UITestCase.SyncContextType.Portable, discoveryOptions.MethodDisplayOrDefault(), testMethod, testMethodArguments: null, settings); - } - - private static IEnumerable GetSettingsAttributes(IXunitTestMethod testMethod) - { - if (testMethod.TestClass.Class.GetCustomAttributes(typeof(UISettingsAttribute), true).SingleOrDefault() is UISettingsAttribute classLevel) - { - yield return classLevel; - } - - if (testMethod.Method.GetCustomAttributes(typeof(UISettingsAttribute), true).SingleOrDefault() is UISettingsAttribute methodLevel) - { - yield return methodLevel; - } + return UIUtilities.CreateTestCase(TestCaseKind.Fact, discoveryOptions, testMethod, factAttribute, null); } } diff --git a/src/Xunit.StaFact/Sdk/UITestCase.cs b/src/Xunit.StaFact/Sdk/UITestCase.cs index 19eb3a55..e6d855a8 100644 --- a/src/Xunit.StaFact/Sdk/UITestCase.cs +++ b/src/Xunit.StaFact/Sdk/UITestCase.cs @@ -1,4 +1,4 @@ -// Copyright (c) Andrew Arnott. All rights reserved. +// Copyright (c) Andrew Arnott. All rights reserved. // Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. using System.ComponentModel; @@ -28,12 +28,21 @@ public UITestCase() /// /// Initializes a new instance of the class. /// + /// The test settings to apply. /// The type of to use. - /// The message sink used to send diagnostic messages. - /// Default method display to use (when not customized). /// The test method this test case belongs to. - /// The test settings to apply. - /// The arguments for the test method. + /// The display name for the test case. + /// The unique ID for the test case. + /// Indicates whether the test case was marked as explicit. + /// The value obtained from . + /// The value obtained from . + /// The value obtained from . + /// The value obtained from . + /// The optional traits list. + /// The optional arguments for the test method. + /// The optional source file in where this test case originated. + /// The optional source line number where this test case originated. + /// The optional timeout for the test case (in milliseconds). internal UITestCase( UISettingsAttribute settings, SyncContextType synchronizationContextType, @@ -115,7 +124,11 @@ protected override void Deserialize(IXunitSerializationInfo data) { MaxAttempts = data.GetValue(nameof(UISettingsAttribute.MaxAttempts)), }; - this.synchronizationContextType = (SyncContextType)data.GetValue(nameof(this.synchronizationContextType), typeof(SyncContextType)); + string? syncContextTypeName = data.GetValue(nameof(this.synchronizationContextType)); + if (syncContextTypeName is not null) + { + this.synchronizationContextType = (SyncContextType)Enum.Parse(typeof(SyncContextType), syncContextTypeName); + } } /// diff --git a/src/Xunit.StaFact/Sdk/UITheoryDiscoverer.cs b/src/Xunit.StaFact/Sdk/UITheoryDiscoverer.cs index d0cab559..2100dbda 100644 --- a/src/Xunit.StaFact/Sdk/UITheoryDiscoverer.cs +++ b/src/Xunit.StaFact/Sdk/UITheoryDiscoverer.cs @@ -11,16 +11,24 @@ public class UITheoryDiscoverer : TheoryDiscoverer /// protected override ValueTask> CreateTestCasesForDataRow(ITestFrameworkDiscoveryOptions discoveryOptions, IXunitTestMethod testMethod, ITheoryAttribute theoryAttribute, ITheoryDataRow dataRow, object?[] testMethodArguments) { - UISettingsAttribute settings = UIFactDiscoverer.GetSettings(testMethod); - IXunitTestCase testCase = new UITestCase(UITestCase.SyncContextType.Portable, discoveryOptions.MethodDisplayOrDefault(), testMethod, dataRow, settings); + IXunitTestCase testCase = UIUtilities.CreateTestCase( + TestCaseKind.DataRow, + discoveryOptions, + testMethod, + theoryAttribute, + testMethodArguments); return new([testCase]); } /// protected override ValueTask> CreateTestCasesForTheory(ITestFrameworkDiscoveryOptions discoveryOptions, IXunitTestMethod testMethod, ITheoryAttribute theoryAttribute) { - UISettingsAttribute settings = UIFactDiscoverer.GetSettings(testMethod); - IXunitTestCase testCase = new UITheoryTestCase(UITestCase.SyncContextType.Portable, discoveryOptions.MethodDisplayOrDefault(), TestMethodDisplayOptions.None, testMethod, settings); + IXunitTestCase testCase = UIUtilities.CreateTestCase( + TestCaseKind.DelayEnumerated, + discoveryOptions, + testMethod, + theoryAttribute, + null); return new([testCase]); } } diff --git a/src/Xunit.StaFact/Sdk/UITheoryTestCase.cs b/src/Xunit.StaFact/Sdk/UITheoryTestCase.cs deleted file mode 100644 index b3f39c3b..00000000 --- a/src/Xunit.StaFact/Sdk/UITheoryTestCase.cs +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (c) Andrew Arnott. All rights reserved. -// Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. - -using System.ComponentModel; - -namespace Xunit.Sdk; - -public class UITheoryTestCase : XunitTheoryTestCase -{ - [EditorBrowsable(EditorBrowsableState.Never)] - [Obsolete("Called by the de-serializer; should only be called by deriving classes for de-serialization purposes")] - public UITheoryTestCase() - { - } - - internal UITheoryTestCase(UITestCase.SyncContextType synchronizationContextType, TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, ITestMethod testMethod, UISettingsAttribute settings) - : base(defaultMethodDisplay, defaultMethodDisplayOptions, testMethod) - { - this.Settings = settings; - settings.ApplyTraits(this); - this.SynchronizationContextType = synchronizationContextType; - } - - internal UISettingsAttribute Settings { get; private set; } = UISettingsAttribute.Default; - - internal UITestCase.SyncContextType SynchronizationContextType { get; private set; } - - public override async Task RunAsync(IMessageSink diagnosticMessageSink, IMessageBus messageBus, object[] constructorArguments, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource) - { - using ThreadRental threadRental = await ThreadRental.CreateAsync(UITestCase.GetAdapter(this.SynchronizationContextType), this.TestMethod); - await threadRental.SynchronizationContext; - - // TODO: retry here if any test cases failed - return await new UITheoryTestCaseRunner(this, this.DisplayName, this.SkipReason, constructorArguments, diagnosticMessageSink, messageBus, aggregator, cancellationTokenSource, threadRental).RunAsync(); - } - - public override void Deserialize(IXunitSerializationInfo data) - { - if (data is null) - { - throw new ArgumentNullException(nameof(data)); - } - - base.Deserialize(data); - - this.Settings = new UISettingsAttribute() { MaxAttempts = data.GetValue(nameof(UISettingsAttribute.MaxAttempts)) }; - this.SynchronizationContextType = (UITestCase.SyncContextType)Enum.Parse(typeof(UITestCase.SyncContextType), data.GetValue("SyncContextType")); - } - - public override void Serialize(IXunitSerializationInfo data) - { - if (data is null) - { - throw new ArgumentNullException(nameof(data)); - } - - base.Serialize(data); - - data.AddValue(nameof(UISettingsAttribute.MaxAttempts), this.Settings.MaxAttempts); - data.AddValue("SyncContextType", this.SynchronizationContextType.ToString()); - } -} diff --git a/src/Xunit.StaFact/Sdk/UIUtilities.cs b/src/Xunit.StaFact/Sdk/UIUtilities.cs new file mode 100644 index 00000000..163c05ec --- /dev/null +++ b/src/Xunit.StaFact/Sdk/UIUtilities.cs @@ -0,0 +1,24 @@ +// Copyright (c) Andrew Arnott. All rights reserved. +// Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. + +namespace Xunit.Sdk; + +internal static class UIUtilities +{ + internal static IXunitTestCase CreateTestCase( + TestCaseKind kind, + ITestFrameworkDiscoveryOptions discoveryOptions, + IXunitTestMethod testMethod, + IFactAttribute factAttribute, + object?[]? testMethodArguments) + { + return Utilities.CreateTestCase( + kind, + UITestCase.SyncContextType.Portable, + null, + discoveryOptions, + testMethod, + factAttribute, + testMethodArguments); + } +} diff --git a/src/Xunit.StaFact/Sdk/Utilities.cs b/src/Xunit.StaFact/Sdk/Utilities.cs index f2098ea7..bd606607 100644 --- a/src/Xunit.StaFact/Sdk/Utilities.cs +++ b/src/Xunit.StaFact/Sdk/Utilities.cs @@ -1,12 +1,108 @@ -// Copyright (c) Andrew Arnott. All rights reserved. +// Copyright (c) Andrew Arnott. All rights reserved. // Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. using System.Runtime.CompilerServices; +using Xunit.Internal; namespace Xunit.Sdk; internal static class Utilities { + internal static IXunitTestCase CreateTestCase( + TestCaseKind kind, + UITestCase.SyncContextType synchronizationContextType, + string? skipReason, + ITestFrameworkDiscoveryOptions discoveryOptions, + IXunitTestMethod testMethod, + IFactAttribute attribute, + object?[]? testMethodArguments) + { + (string TestCaseDisplayName, bool Explicit, string? SkipReason, Type? SkipType, string? SkipUnless, string? SkipWhen, int Timeout, string UniqueID, IXunitTestMethod ResolvedTestMethod) details; + Dictionary> traits; + UISettingsAttribute settings; + + details = TestIntrospectionHelper.GetTestCaseDetails(discoveryOptions, testMethod, attribute); + settings = GetSettings(testMethod); + traits = testMethod.Traits.ToReadWrite(StringComparer.OrdinalIgnoreCase); + + if (skipReason is not null) + { + return new SkippedTestCase( + details.ResolvedTestMethod, + details.TestCaseDisplayName, + details.UniqueID, + details.Explicit, + skipReason, + traits, + testMethodArguments); + } + + if (kind == TestCaseKind.DelayEnumerated) + { + return new UIDelayEnumeratedTestCase( + settings, + synchronizationContextType, + details.ResolvedTestMethod, + details.TestCaseDisplayName, + details.UniqueID, + details.Explicit, + (attribute as ITheoryAttribute)?.SkipTestWithoutData ?? false, + details.SkipReason, + details.SkipType, + details.SkipUnless, + details.SkipWhen, + traits, + timeout: details.Timeout); + } + + // Fact and DataRow test case kinds both result in a UITestCase. + // The only difference is that DataRow should have test method + // arguments, and Fact should not. The caller should pass null + // for the test method arguments when the test case kind is Fact, + // so we can use the same code path for both kinds. + return new UITestCase( + settings, + synchronizationContextType, + details.ResolvedTestMethod, + details.TestCaseDisplayName, + details.UniqueID, + details.Explicit, + details.SkipReason, + details.SkipType, + details.SkipUnless, + details.SkipWhen, + traits, + null, + timeout: details.Timeout); + } + + private static UISettingsAttribute GetSettings(IXunitTestMethod testMethod) + { + // Initialize with defaults. + UISettingsAttribute settings = UISettingsAttribute.Default; + + // Enumerate through each attribute (each progressively overriding the previous) and apply any explicitly set values to the attribute we'll return. + foreach (UISettingsAttribute settingsAttribute in GetSettingsAttributes(testMethod)) + { + settings.MaxAttempts = settingsAttribute.MaxAttempts; + } + + return settings; + } + + private static IEnumerable GetSettingsAttributes(IXunitTestMethod testMethod) + { + if (testMethod.TestClass.Class.GetCustomAttributes(typeof(UISettingsAttribute), true).SingleOrDefault() is UISettingsAttribute classLevel) + { + yield return classLevel; + } + + if (testMethod.Method.GetCustomAttributes(typeof(UISettingsAttribute), true).SingleOrDefault() is UISettingsAttribute methodLevel) + { + yield return methodLevel; + } + } + internal static SyncContextAwaiter GetAwaiter(this SynchronizationContext synchronizationContext) => new SyncContextAwaiter(synchronizationContext); internal struct SyncContextAwaiter : ICriticalNotifyCompletion From 05ff98f50b8bbe9e3cb3a79b421a9428e4f40515 Mon Sep 17 00:00:00 2001 From: reduckted Date: Fri, 10 Jan 2025 22:15:04 +1000 Subject: [PATCH 08/27] Implemented the test runner. --- src/Xunit.StaFact/Sdk/ThreadRental.cs | 4 +- .../Sdk/UIDelayEnumeratedTestCase.cs | 67 +++-- .../Sdk/UISynchronizationContext.cs | 6 +- src/Xunit.StaFact/Sdk/UITestCase.cs | 96 +++---- src/Xunit.StaFact/Sdk/UITestCaseRunner.cs | 181 +++++++++++- .../Sdk/UITestCaseRunnerContext.cs | 29 ++ src/Xunit.StaFact/Sdk/UITestRunner.cs | 268 ++++++++---------- src/Xunit.StaFact/Sdk/UITestRunnerContext.cs | 27 ++ .../Sdk/UITheoryTestCaseRunner.cs | 22 -- 9 files changed, 439 insertions(+), 261 deletions(-) create mode 100644 src/Xunit.StaFact/Sdk/UITestCaseRunnerContext.cs create mode 100644 src/Xunit.StaFact/Sdk/UITestRunnerContext.cs delete mode 100644 src/Xunit.StaFact/Sdk/UITheoryTestCaseRunner.cs diff --git a/src/Xunit.StaFact/Sdk/ThreadRental.cs b/src/Xunit.StaFact/Sdk/ThreadRental.cs index 1b5fa341..51f6d190 100644 --- a/src/Xunit.StaFact/Sdk/ThreadRental.cs +++ b/src/Xunit.StaFact/Sdk/ThreadRental.cs @@ -1,4 +1,4 @@ -// Copyright (c) Andrew Arnott. All rights reserved. +// Copyright (c) Andrew Arnott. All rights reserved. // Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. using System.Runtime.InteropServices; @@ -44,7 +44,7 @@ internal static async Task CreateAsync(SyncContextAdapter syncCont { var disposalTaskSource = new TaskCompletionSource(); var syncContextSource = new TaskCompletionSource(); - var threadName = $"{testMethod.TestClass.Class.Name}.{testMethod.Method.Name}"; + var threadName = $"{testMethod.TestClass.TestClassName}.{testMethod.MethodName}"; var thread = new Thread(() => { SynchronizationContext uiSyncContext = syncContextAdapter.Create(threadName); diff --git a/src/Xunit.StaFact/Sdk/UIDelayEnumeratedTestCase.cs b/src/Xunit.StaFact/Sdk/UIDelayEnumeratedTestCase.cs index e54250e3..4cccfb01 100644 --- a/src/Xunit.StaFact/Sdk/UIDelayEnumeratedTestCase.cs +++ b/src/Xunit.StaFact/Sdk/UIDelayEnumeratedTestCase.cs @@ -5,8 +5,11 @@ namespace Xunit.Sdk; -public class UIDelayEnumeratedTestCase : XunitDelayEnumeratedTheoryTestCase +public class UIDelayEnumeratedTestCase : XunitDelayEnumeratedTheoryTestCase, ISelfExecutingXunitTestCase { + private UISettingsAttribute settings = UISettingsAttribute.Default; + private UITestCase.SyncContextType synchronizationContextType; + [EditorBrowsable(EditorBrowsableState.Never)] [Obsolete("Called by the de-serializer; should only be called by deriving classes for de-serialization purposes")] public UIDelayEnumeratedTestCase() @@ -31,51 +34,61 @@ internal UIDelayEnumeratedTestCase( int? timeout = null) : base(testMethod, testCaseDisplayName, uniqueID, @explicit, skipTestWithoutData, skipReason, skipType, skipUnless, skipWhen, traits, sourceFilePath, sourceLineNumber, timeout) { - this.Settings = settings; - this.SynchronizationContextType = synchronizationContextType; + this.settings = settings; + this.synchronizationContextType = synchronizationContextType; } - internal UISettingsAttribute Settings { get; private set; } = UISettingsAttribute.Default; - - internal UITestCase.SyncContextType SynchronizationContextType { get; private set; } - - public Task RunAsync(IMessageSink diagnosticMessageSink, IMessageBus messageBus, object[] constructorArguments, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource) + public ValueTask Run( + ExplicitOption explicitOption, + IMessageBus messageBus, + object?[] constructorArguments, + ExceptionAggregator aggregator, + CancellationTokenSource cancellationTokenSource) { - using ThreadRental threadRental = await ThreadRental.CreateAsync(UITestCase.GetAdapter(this.SynchronizationContextType), this.TestMethod); - await threadRental.SynchronizationContext; + if (cancellationTokenSource is null) + { + throw new ArgumentNullException(nameof(cancellationTokenSource)); + } - // TODO: retry here if any test cases failed - return await new UITestCaseRunner(this, this.DisplayName, this.SkipReason, constructorArguments, diagnosticMessageSink, messageBus, aggregator, cancellationTokenSource, threadRental).RunAsync(); + return UITestCaseRunner.Run( + this, + UITestCase.GetAdapter(this.synchronizationContextType), + this.settings, + explicitOption, + messageBus, + constructorArguments, + aggregator, + cancellationTokenSource); } - protected override void Deserialize(IXunitSerializationInfo data) + protected override void Serialize(IXunitSerializationInfo data) { if (data is null) { throw new ArgumentNullException(nameof(data)); } - base.Deserialize(data); - - this.Settings = new UISettingsAttribute() { MaxAttempts = data.GetValue(nameof(UISettingsAttribute.MaxAttempts)) }; - - string? syncContextTypeName = data.GetValue("SyncContextType"); - if (syncContextTypeName is not null) - { - this.SynchronizationContextType = (UITestCase.SyncContextType)Enum.Parse(typeof(UITestCase.SyncContextType), syncContextTypeName); - } + base.Serialize(data); + data.AddValue(nameof(UISettingsAttribute.MaxAttempts), this.settings.MaxAttempts); + data.AddValue(nameof(this.synchronizationContextType), this.synchronizationContextType); } - protected override void Serialize(IXunitSerializationInfo data) + protected override void Deserialize(IXunitSerializationInfo data) { if (data is null) { throw new ArgumentNullException(nameof(data)); } - base.Serialize(data); - - data.AddValue(nameof(UISettingsAttribute.MaxAttempts), this.Settings.MaxAttempts); - data.AddValue("SyncContextType", this.SynchronizationContextType.ToString()); + base.Deserialize(data); + this.settings = new() + { + MaxAttempts = data.GetValue(nameof(UISettingsAttribute.MaxAttempts)), + }; + string? syncContextTypeName = data.GetValue(nameof(this.synchronizationContextType)); + if (syncContextTypeName is not null) + { + this.synchronizationContextType = (UITestCase.SyncContextType)Enum.Parse(typeof(UITestCase.SyncContextType), syncContextTypeName); + } } } diff --git a/src/Xunit.StaFact/Sdk/UISynchronizationContext.cs b/src/Xunit.StaFact/Sdk/UISynchronizationContext.cs index ccb57ed7..3f3f1e73 100644 --- a/src/Xunit.StaFact/Sdk/UISynchronizationContext.cs +++ b/src/Xunit.StaFact/Sdk/UISynchronizationContext.cs @@ -1,4 +1,4 @@ -// Copyright (c) Andrew Arnott. All rights reserved. +// Copyright (c) Andrew Arnott. All rights reserved. // Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. using System.Runtime.ExceptionServices; @@ -199,9 +199,9 @@ private bool TryOneWorkItem() try { - if (this.aggregator is object) + if (this.aggregator.HasValue) { - this.aggregator.Run(() => work.Key(work.Value)); + this.aggregator.Value.Run(() => work.Key(work.Value)); } else { diff --git a/src/Xunit.StaFact/Sdk/UITestCase.cs b/src/Xunit.StaFact/Sdk/UITestCase.cs index e6d855a8..9c1ea62d 100644 --- a/src/Xunit.StaFact/Sdk/UITestCase.cs +++ b/src/Xunit.StaFact/Sdk/UITestCase.cs @@ -3,6 +3,7 @@ using System.ComponentModel; using System.Diagnostics; +using static Xunit.Sdk.UISynchronizationContext; namespace Xunit.Sdk; @@ -10,7 +11,7 @@ namespace Xunit.Sdk; /// Wraps test cases for FactAttribute and TheoryAttribute so the test case runs on the WPF STA thread. /// [DebuggerDisplay(@"\{ class = {TestMethod.TestClass.Class.Name}, method = {TestMethod.Method.Name}, display = {DisplayName}, skip = {SkipReason} \}")] -public class UITestCase : XunitTestCase +public class UITestCase : XunitTestCase, ISelfExecutingXunitTestCase { private UISettingsAttribute settings = UISettingsAttribute.Default; private SyncContextType synchronizationContextType; @@ -98,44 +99,11 @@ public enum SyncContextType #endif } - private SyncContextAdapter Adapter => GetAdapter(this.synchronizationContextType); - - protected override void Serialize(IXunitSerializationInfo data) - { - if (data is null) - { - throw new ArgumentNullException(nameof(data)); - } - - base.Serialize(data); - data.AddValue(nameof(UISettingsAttribute.MaxAttempts), this.settings.MaxAttempts); - data.AddValue(nameof(this.synchronizationContextType), this.synchronizationContextType); - } - - protected override void Deserialize(IXunitSerializationInfo data) - { - if (data is null) - { - throw new ArgumentNullException(nameof(data)); - } - - base.Deserialize(data); - this.settings = new() - { - MaxAttempts = data.GetValue(nameof(UISettingsAttribute.MaxAttempts)), - }; - string? syncContextTypeName = data.GetValue(nameof(this.synchronizationContextType)); - if (syncContextTypeName is not null) - { - this.synchronizationContextType = (SyncContextType)Enum.Parse(typeof(SyncContextType), syncContextTypeName); - } - } - /// - public override Task RunAsync( - IMessageSink diagnosticMessageSink, + public ValueTask Run( + ExplicitOption explicitOption, IMessageBus messageBus, - object[] constructorArguments, + object?[] constructorArguments, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource) { @@ -144,20 +112,15 @@ public override Task RunAsync( throw new ArgumentNullException(nameof(cancellationTokenSource)); } - var task = Task.Run( - async () => - { - using ThreadRental threadRental = await ThreadRental.CreateAsync(this.Adapter, this.TestMethod); - await threadRental.SynchronizationContext; - var runner = new UITestCaseRunner(this, this.DisplayName, this.SkipReason, constructorArguments, this.TestMethodArguments, messageBus, aggregator, cancellationTokenSource, this.settings, threadRental); - return await runner.RunAsync(); - }, - cancellationTokenSource.Token); - - // We need to block the XUnit thread to ensure its concurrency throttle is effective. - // See https://github.com/AArnott/Xunit.StaFact/pull/55#issuecomment-826187354 for details. - RunSummary runSummary = task.GetAwaiter().GetResult(); - return Task.FromResult(runSummary); + return UITestCaseRunner.Run( + this, + GetAdapter(this.synchronizationContextType), + this.settings, + explicitOption, + messageBus, + constructorArguments, + aggregator, + cancellationTokenSource); } internal static SyncContextAdapter GetAdapter(SyncContextType syncContextType) @@ -185,6 +148,37 @@ internal static SyncContextAdapter GetAdapter(SyncContextType syncContextType) } } + protected override void Serialize(IXunitSerializationInfo data) + { + if (data is null) + { + throw new ArgumentNullException(nameof(data)); + } + + base.Serialize(data); + data.AddValue(nameof(UISettingsAttribute.MaxAttempts), this.settings.MaxAttempts); + data.AddValue(nameof(this.synchronizationContextType), this.synchronizationContextType); + } + + protected override void Deserialize(IXunitSerializationInfo data) + { + if (data is null) + { + throw new ArgumentNullException(nameof(data)); + } + + base.Deserialize(data); + this.settings = new() + { + MaxAttempts = data.GetValue(nameof(UISettingsAttribute.MaxAttempts)), + }; + string? syncContextTypeName = data.GetValue(nameof(this.synchronizationContextType)); + if (syncContextTypeName is not null) + { + this.synchronizationContextType = (SyncContextType)Enum.Parse(typeof(SyncContextType), syncContextTypeName); + } + } + private class NullAdapter : UISynchronizationContext.Adapter { internal static new readonly NullAdapter Default = new NullAdapter(); diff --git a/src/Xunit.StaFact/Sdk/UITestCaseRunner.cs b/src/Xunit.StaFact/Sdk/UITestCaseRunner.cs index 2532b779..639465c0 100644 --- a/src/Xunit.StaFact/Sdk/UITestCaseRunner.cs +++ b/src/Xunit.StaFact/Sdk/UITestCaseRunner.cs @@ -1,12 +1,14 @@ -// Copyright (c) Andrew Arnott. All rights reserved. +// Copyright (c) Andrew Arnott. All rights reserved. // Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. +using System.Text; + namespace Xunit.Sdk; -public class UITestCaseRunner : XunitTestCaseRunner +public class UITestCaseRunner : XunitTestCaseRunnerBase { - private UISettingsAttribute settings; - private ThreadRental threadRental; + private readonly UISettingsAttribute settings; + private readonly ThreadRental threadRental; /// /// Initializes a new instance of the class. @@ -21,13 +23,120 @@ internal UITestCaseRunner( this.threadRental = threadRental; } - protected override async ValueTask RunTest(XunitTestCaseRunnerContext ctxt, IXunitTest test) + public async ValueTask Run( + IXunitTestCase testCase, + IMessageBus messageBus, + ExceptionAggregator aggregator, + CancellationTokenSource cancellationTokenSource, + string displayName, + string? skipReason, + ExplicitOption explicitOption, + object?[] constructorArguments) + { + if (testCase is null) + { + throw new ArgumentNullException(nameof(testCase)); + } + + // This code comes from XunitRunnerHelper.RunXunitTestCase, + // and it's centralized here just so we don't have to duplicate + // it in both `UITestCase` and `UITheoryTestCase`. + IReadOnlyCollection tests = await aggregator.RunAsync(testCase.CreateTests, []); + + if (aggregator.ToException() is Exception ex) + { + if (ex.Message.StartsWith(DynamicSkipToken.Value, StringComparison.Ordinal)) + { + return XunitRunnerHelper.SkipTestCases( + messageBus, + cancellationTokenSource, + [testCase], + ex.Message.Substring(DynamicSkipToken.Value.Length), + sendTestCaseMessages: false); + } + else + { + return XunitRunnerHelper.FailTestCases( + messageBus, + cancellationTokenSource, + [testCase], + ex, + sendTestCaseMessages: false); + } + } + + await using UITestCaseRunnerContext ctxt = new( + this.settings, + this.threadRental, + testCase, + tests, + messageBus, + aggregator, + cancellationTokenSource, + displayName, + skipReason, + explicitOption, + constructorArguments); + + await ctxt.InitializeAsync(); + + return await this.Run(ctxt); + } + + internal static ValueTask Run( + IXunitTestCase testCase, + SyncContextAdapter adapter, + UISettingsAttribute settings, + ExplicitOption explicitOption, + IMessageBus messageBus, + object?[] constructorArguments, + ExceptionAggregator aggregator, + CancellationTokenSource cancellationTokenSource) + { + var task = Task.Run( + async () => + { + using ThreadRental threadRental = await ThreadRental.CreateAsync(adapter, testCase.TestMethod); + await threadRental.SynchronizationContext; + var runner = new UITestCaseRunner(settings, threadRental); + return await runner.Run( + testCase, + messageBus, + aggregator, + cancellationTokenSource, + testCase.TestCaseDisplayName, + testCase.SkipReason, + explicitOption, + constructorArguments); + }, + cancellationTokenSource.Token); + + // We need to block the XUnit thread to ensure its concurrency throttle is effective. + // See https://github.com/AArnott/Xunit.StaFact/pull/55#issuecomment-826187354 for details. + return new(task.GetAwaiter().GetResult()); + } + + protected async override ValueTask RunTest(UITestCaseRunnerContext ctxt, IXunitTest test) { + if (ctxt is null) + { + throw new ArgumentNullException(nameof(ctxt)); + } + RunSummary result = default; for (int i = 0; i < this.settings.MaxAttempts; i++) { bool finalAttempt = i == this.settings.MaxAttempts - 1; - RunSummary summary = await new UITestRunner(new XunitTest(this.TestCase, this.DisplayName), this.MessageBus, finalAttempt, this.TestClass, this.ConstructorArguments, this.TestMethod, this.TestMethodArguments, this.SkipReason, this.BeforeAfterAttributes, this.Aggregator, this.CancellationTokenSource, this.threadRental).RunAsync(); + RunSummary summary = await UITestRunner.Instance.Run( + ctxt.Settings, + ctxt.ThreadRental, + test, + finalAttempt ? ctxt.MessageBus : new FilteringMessageBus(ctxt.MessageBus), + ctxt.ConstructorArguments, + ctxt.ExplicitOption, + ctxt.Aggregator.Clone(), + ctxt.CancellationTokenSource, + ctxt.BeforeAfterTestAttributes); result.Aggregate(summary); if (summary.Failed == 0) { @@ -37,4 +146,64 @@ protected override async ValueTask RunTest(XunitTestCaseRunnerContex return result; } + + private sealed class FilteringMessageBus : IMessageBus + { + private readonly IMessageBus messageBus; + + public FilteringMessageBus(IMessageBus messageBus) + { + this.messageBus = messageBus; + } + + public void Dispose() + { + this.messageBus.Dispose(); + } + + public bool QueueMessage(IMessageSinkMessage message) + { + if (message is ITestFailed testFailed) + { + message = ReportFailure("Test", testFailed); + } + else if (message is ITestCleanupFailure testCleanupFailure) + { + message = ReportFailure("Test cleanup", testCleanupFailure); + } + + return this.messageBus.QueueMessage(message); + + static IMessageSinkMessage ReportFailure(string header, T message) + where T : ITestMessage, IErrorMetadata + { + // This test will run again; report it as skipped instead of failed. + StringBuilder failures = new(); + failures.AppendLine($"{header} failed and will automatically retry. Failure details follow:"); + + for (int i = 0; i < message.Messages.Length; i++) + { + failures.AppendLine(message.Messages[i]); + failures.AppendLine(message.StackTraces[i]); + } + + IExecutionMetadata? executionMetadata = message as IExecutionMetadata; + ITestResultMessage? testResultMessage = message as ITestResultMessage; + return new TestSkipped + { + Reason = failures.ToString(), + AssemblyUniqueID = message.AssemblyUniqueID, + TestCollectionUniqueID = message.TestCollectionUniqueID, + TestClassUniqueID = message.TestClassUniqueID, + TestMethodUniqueID = message.TestMethodUniqueID, + TestUniqueID = message.TestUniqueID, + TestCaseUniqueID = message.TestCaseUniqueID, + Output = executionMetadata?.Output ?? string.Empty, + Warnings = executionMetadata?.Warnings ?? [], + ExecutionTime = executionMetadata?.ExecutionTime ?? 0, + FinishTime = testResultMessage?.FinishTime ?? DateTimeOffset.Now, + }; + } + } + } } diff --git a/src/Xunit.StaFact/Sdk/UITestCaseRunnerContext.cs b/src/Xunit.StaFact/Sdk/UITestCaseRunnerContext.cs new file mode 100644 index 00000000..5f4877bb --- /dev/null +++ b/src/Xunit.StaFact/Sdk/UITestCaseRunnerContext.cs @@ -0,0 +1,29 @@ +// Copyright (c) Andrew Arnott. All rights reserved. +// Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. + +namespace Xunit.Sdk; + +public class UITestCaseRunnerContext : XunitTestCaseRunnerBaseContext +{ + internal UITestCaseRunnerContext( + UISettingsAttribute settings, + ThreadRental threadRental, + IXunitTestCase testCase, + IReadOnlyCollection tests, + IMessageBus messageBus, + ExceptionAggregator aggregator, + CancellationTokenSource cancellationTokenSource, + string displayName, + string? skipReason, + ExplicitOption explicitOption, + object?[] constructorArguments) + : base(testCase, tests, messageBus, aggregator, cancellationTokenSource, displayName, skipReason, explicitOption, constructorArguments) + { + this.Settings = settings; + this.ThreadRental = threadRental; + } + + public UISettingsAttribute Settings { get; } + + internal ThreadRental ThreadRental { get; } +} diff --git a/src/Xunit.StaFact/Sdk/UITestRunner.cs b/src/Xunit.StaFact/Sdk/UITestRunner.cs index 34916b85..5afc2a74 100644 --- a/src/Xunit.StaFact/Sdk/UITestRunner.cs +++ b/src/Xunit.StaFact/Sdk/UITestRunner.cs @@ -1,184 +1,152 @@ -// Copyright (c) Andrew Arnott. All rights reserved. +// Copyright (c) Andrew Arnott. All rights reserved. // Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. -using System.Reflection; -using System.Text; - namespace Xunit.Sdk; -public class UITestRunner : XunitTestRunner +public class UITestRunner : XunitTestRunnerBase { - private readonly ThreadRental threadRental; - - internal UITestRunner(ThreadRental threadRental) + public static UITestRunner Instance { get; } = new(); + + internal async ValueTask Run( + UISettingsAttribute settings, + ThreadRental threadRental, + IXunitTest test, + IMessageBus messageBus, + object?[] constructorArguments, + ExplicitOption explicitOption, + ExceptionAggregator aggregator, + CancellationTokenSource cancellationTokenSource, + IReadOnlyCollection beforeAfterAttributes) { - this.threadRental = threadRental; + await using UITestRunnerContext ctxt = new( + settings, + threadRental, + test, + messageBus, + explicitOption, + aggregator, + cancellationTokenSource, + beforeAfterAttributes, + constructorArguments); + + await ctxt.InitializeAsync(); + + return await this.Run(ctxt); } - protected override async ValueTask InvokeTest(XunitTestRunnerContext ctxt, object? testClassInstance) + protected async override ValueTask RunTest(UITestRunnerContext ctxt) { - if (this.threadRental.SynchronizationContext is UISynchronizationContext syncContext) + if (ctxt is null) { - syncContext.SetExceptionAggregator(ctxt.Aggregator); + throw new ArgumentNullException(nameof(ctxt)); } - await ctxt.Aggregator.RunAsync(async delegate + if (ctxt.ThreadRental.SynchronizationContext is UISynchronizationContext uiSyncContext) { - if (!ctxt.CancellationTokenSource.IsCancellationRequested) + uiSyncContext.SetExceptionAggregator(ctxt.Aggregator); + } + + object? testClassInstance = null; + TimeSpan elapsedTime = TimeSpan.Zero; + + if (!ctxt.Aggregator.HasExceptions) + { + SynchronizationContext? syncContext = null; + ExecutionContext? executionContext = null; + + elapsedTime += await ExecutionTimer.MeasureAsync(() => ctxt.Aggregator.RunAsync(async () => { - await this.threadRental.SynchronizationContext; - var testClassInstance = this.CreateTestClass(); + await ctxt.ThreadRental.SynchronizationContext; + (testClassInstance, syncContext, executionContext) = await this.CreateTestClassInstance(ctxt); + })); + + TaskCompletionSource finished = new(); + + if (executionContext is not null) + { + ExecutionContext.Run(executionContext, RunTest, null); + } + else + { + RunTest(null); + } + + await finished.Task; + + async void RunTest(object? state) + { + // At this point, xUnit would set the synchronization context to + // the one that was used when creating the test class. We have + // our synchronization context that we use, so we don't do that. + this.UpdateTestContext(testClassInstance); try { - var asyncLifetime = testClassInstance as IAsyncLifetime; - if (asyncLifetime is object) + if (!ctxt.Aggregator.HasExceptions) { - await this.threadRental.SynchronizationContext; - await asyncLifetime.InitializeAsync(); - } - - if (!ctxt.CancellationTokenSource.IsCancellationRequested) - { - await this.threadRental.SynchronizationContext; - ctxt.RunBeforeAttributes(); + elapsedTime += await ExecutionTimer.MeasureAsync(async () => + { + await ctxt.ThreadRental.SynchronizationContext; + ctxt.Aggregator.Run(() => this.PreInvoke(ctxt)); + }); if (!ctxt.Aggregator.HasExceptions) { - if (!ctxt.CancellationTokenSource.IsCancellationRequested) - { - await this.Timer.AggregateAsync( - async () => + elapsedTime += await ctxt.Aggregator.RunAsync( + async () => + { + await ctxt.ThreadRental.SynchronizationContext; + TimeSpan invokeTime = await this.InvokeTest(ctxt, testClassInstance); + + if (ctxt.ThreadRental.SyncContextAdapter.CanCompleteOperations) { - var parameterCount = this.TestMethod.GetParameters().Length; - var valueCount = this.TestMethodArguments == null ? 0 : this.TestMethodArguments.Length; - if (parameterCount != valueCount) - { - this.Aggregator.Add( - new InvalidOperationException( - $"The test method expected {parameterCount} parameter value{(parameterCount == 1 ? string.Empty : "s")}, but {valueCount} parameter value{(valueCount == 1 ? string.Empty : "s")} {(valueCount == 1 ? "was" : "were")} provided.")); - } - else + invokeTime += await ExecutionTimer.MeasureAsync(async () => { - await this.threadRental.SynchronizationContext; - object? result = null; - try - { - result = this.CallTestMethod(testClassInstance); - } - catch (TargetInvocationException ex) - { - this.Aggregator.Add(ex.InnerException); - } - - if (result is Task task) - { - await task.NoThrowAwaitable(); - if (task.IsFaulted) - { - this.Aggregator.Add(task.Exception!.Flatten().InnerException ?? task.Exception); - } - else if (task.IsCanceled) - { - try - { - // In order to get the original exception, in order to preserve the callstack, - // we must "rethrow" the exception. - task.GetAwaiter().GetResult(); - } - catch (OperationCanceledException ex) - { - this.Aggregator.Add(ex); - } - } - } - else if (this.threadRental.SyncContextAdapter.CanCompleteOperations) - { - await this.threadRental.SyncContextAdapter.WaitForOperationCompletionAsync(this.threadRental.SynchronizationContext).ConfigureAwait(false); - } - } - }); - } - - await this.threadRental.SynchronizationContext; - ctxt.RunAfterAttributes(); + await ctxt.ThreadRental.SyncContextAdapter.WaitForOperationCompletionAsync(ctxt.ThreadRental.SynchronizationContext).ConfigureAwait(false); + }); + } + + return invokeTime; + }, + TimeSpan.Zero); + + // Set an early version of TestResultState so anything done in PostInvoke can understand whether + // it looks like the test is passing, failing, or dynamically skipped + var currentException = ctxt.Aggregator.ToException(); + var currentSkipReason = ctxt.GetSkipReason(currentException); + var currentExecutionTime = (decimal)elapsedTime.TotalMilliseconds; + TestResultState testResultState = + currentSkipReason is not null + ? TestResultState.ForSkipped(currentExecutionTime) + : TestResultState.FromException(currentExecutionTime, currentException); + + this.UpdateTestContext(testClassInstance, testResultState); + + elapsedTime += await ExecutionTimer.MeasureAsync(() => ctxt.Aggregator.RunAsync(async () => + { + await ctxt.ThreadRental.SynchronizationContext; + this.PostInvoke(ctxt); + })); } - } - if (asyncLifetime is object) - { - await this.threadRental.SynchronizationContext; - await ctxt.Aggregator.RunAsync(asyncLifetime.DisposeAsync); + elapsedTime += await ExecutionTimer.MeasureAsync(() => ctxt.Aggregator.RunAsync(async () => + { + await ctxt.ThreadRental.SynchronizationContext; + await this.DisposeTestClassInstance(ctxt, testClassInstance!); + })); + + this.UpdateTestContext(null, TestContext.Current.TestState); } + + finished.TrySetResult(null); } - finally + catch (Exception ex) { - await this.threadRental.SynchronizationContext; - ctxt.Aggregator.Run(() => ctxt.Test.DisposeTestClass(testClassInstance, this.MessageBus, this.Timer, this.CancellationTokenSource)); + finished.TrySetException(ex); } } - }); - - return this.Timer.Total; - } - - private sealed class FilteringMessageBus : IMessageBus - { - private readonly IMessageBus messageBus; - - public FilteringMessageBus(IMessageBus messageBus) - { - this.messageBus = messageBus; - } - - public void Dispose() - { - this.messageBus.Dispose(); } - public bool QueueMessage(IMessageSinkMessage message) - { - if (message is ITestFailed testFailed) - { - message = ReportFailure("Test", testFailed); - } - else if (message is ITestCleanupFailure testCleanupFailure) - { - message = ReportFailure("Test cleanup", testCleanupFailure); - } - - return this.messageBus.QueueMessage(message); - - static IMessageSinkMessage ReportFailure(string header, T message) - where T : ITestMessage, IErrorMetadata - { - // This test will run again; report it as skipped instead of failed. - StringBuilder failures = new(); - failures.AppendLine($"{header} failed and will automatically retry. Failure details follow:"); - - for (int i = 0; i < message.Messages.Length; i++) - { - failures.AppendLine(message.Messages[i]); - failures.AppendLine(message.StackTraces[i]); - } - - IExecutionMetadata? executionMetadata = message as IExecutionMetadata; - ITestResultMessage? testResultMessage = message as ITestResultMessage; - return new TestSkipped - { - Reason = failures.ToString(), - AssemblyUniqueID = message.AssemblyUniqueID, - TestCollectionUniqueID = message.TestCollectionUniqueID, - TestClassUniqueID = message.TestClassUniqueID, - TestMethodUniqueID = message.TestMethodUniqueID, - TestUniqueID = message.TestUniqueID, - TestCaseUniqueID = message.TestCaseUniqueID, - Output = executionMetadata?.Output ?? string.Empty, - Warnings = executionMetadata?.Warnings ?? [], - ExecutionTime = executionMetadata?.ExecutionTime ?? 0, - FinishTime = testResultMessage?.FinishTime ?? DateTimeOffset.Now, - }; - } - } + return elapsedTime; } } diff --git a/src/Xunit.StaFact/Sdk/UITestRunnerContext.cs b/src/Xunit.StaFact/Sdk/UITestRunnerContext.cs new file mode 100644 index 00000000..aee1eb85 --- /dev/null +++ b/src/Xunit.StaFact/Sdk/UITestRunnerContext.cs @@ -0,0 +1,27 @@ +// Copyright (c) Andrew Arnott. All rights reserved. +// Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. + +namespace Xunit.Sdk; + +public class UITestRunnerContext : XunitTestRunnerBaseContext +{ + internal UITestRunnerContext( + UISettingsAttribute settings, + ThreadRental threadRental, + IXunitTest test, + IMessageBus messageBus, + ExplicitOption explicitOption, + ExceptionAggregator aggregator, + CancellationTokenSource cancellationTokenSource, + IReadOnlyCollection beforeAfterTestAttributes, + object?[] constructorArguments) + : base(test, messageBus, explicitOption, aggregator, cancellationTokenSource, beforeAfterTestAttributes, constructorArguments) + { + this.Settings = settings; + this.ThreadRental = threadRental; + } + + public UISettingsAttribute Settings { get; } + + internal ThreadRental ThreadRental { get; } +} diff --git a/src/Xunit.StaFact/Sdk/UITheoryTestCaseRunner.cs b/src/Xunit.StaFact/Sdk/UITheoryTestCaseRunner.cs deleted file mode 100644 index bfbe18d3..00000000 --- a/src/Xunit.StaFact/Sdk/UITheoryTestCaseRunner.cs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) Andrew Arnott. All rights reserved. -// Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. - -using System.Reflection; - -namespace Xunit.Sdk; - -public class UITheoryTestCaseRunner : XunitTheoryTestCaseRunner -{ - private readonly ThreadRental threadRental; - - internal UITheoryTestCaseRunner(UITheoryTestCase testCase, string displayName, string skipReason, object[] constructorArguments, IMessageSink diagnosticMessageSink, IMessageBus messageBus, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource, ThreadRental threadRental) - : base(testCase, displayName, skipReason, constructorArguments, diagnosticMessageSink, messageBus, aggregator, cancellationTokenSource) - { - this.threadRental = threadRental; - } - - internal new UITheoryTestCase TestCase => (UITheoryTestCase)base.TestCase; - - protected override XunitTestRunner CreateTestRunner(ITest test, IMessageBus messageBus, Type testClass, object[] constructorArguments, MethodInfo testMethod, object[] testMethodArguments, string skipReason, IReadOnlyList beforeAfterAttributes, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource) - => new UITestRunner(test, messageBus, finalAttempt: true, testClass, constructorArguments, testMethod, testMethodArguments, skipReason, beforeAfterAttributes, aggregator, cancellationTokenSource, this.threadRental); -} From b8aef619be4a9c0dfb54c8f6d8a8571e331b8e64 Mon Sep 17 00:00:00 2001 From: reduckted Date: Fri, 10 Jan 2025 22:16:35 +1000 Subject: [PATCH 09/27] Implemented new IAsyncLifetime interface corretly. --- test/Xunit.StaFact.Tests/UIFactTests.cs | 6 +++--- test/Xunit.StaFact.Tests/UITheoryTests.cs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test/Xunit.StaFact.Tests/UIFactTests.cs b/test/Xunit.StaFact.Tests/UIFactTests.cs index ae0e6ab6..9dcea6fb 100644 --- a/test/Xunit.StaFact.Tests/UIFactTests.cs +++ b/test/Xunit.StaFact.Tests/UIFactTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Andrew Arnott. All rights reserved. +// Copyright (c) Andrew Arnott. All rights reserved. // Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. using System.Reflection; @@ -22,7 +22,7 @@ public void Dispose() Assert.Same(this.ctorSyncContext, SynchronizationContext.Current); } - public async Task InitializeAsync() + public async ValueTask InitializeAsync() { Assert.Equal(this.ctorThreadId, Environment.CurrentManagedThreadId); Assert.Same(this.ctorSyncContext, SynchronizationContext.Current); @@ -31,7 +31,7 @@ public async Task InitializeAsync() Assert.Same(this.ctorSyncContext, SynchronizationContext.Current); } - public async Task DisposeAsync() + public async ValueTask DisposeAsync() { Assert.Equal(this.ctorThreadId, Environment.CurrentManagedThreadId); Assert.Same(this.ctorSyncContext, SynchronizationContext.Current); diff --git a/test/Xunit.StaFact.Tests/UITheoryTests.cs b/test/Xunit.StaFact.Tests/UITheoryTests.cs index 6a5cabe3..2204f721 100644 --- a/test/Xunit.StaFact.Tests/UITheoryTests.cs +++ b/test/Xunit.StaFact.Tests/UITheoryTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Andrew Arnott. All rights reserved. +// Copyright (c) Andrew Arnott. All rights reserved. // Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. using System.Reflection; @@ -22,7 +22,7 @@ public void Dispose() Assert.Same(this.ctorSyncContext, SynchronizationContext.Current); } - public async Task InitializeAsync() + public async ValueTask InitializeAsync() { Assert.Equal(this.ctorThreadId, Environment.CurrentManagedThreadId); Assert.Same(this.ctorSyncContext, SynchronizationContext.Current); @@ -31,7 +31,7 @@ public async Task InitializeAsync() Assert.Same(this.ctorSyncContext, SynchronizationContext.Current); } - public async Task DisposeAsync() + public async ValueTask DisposeAsync() { Assert.Equal(this.ctorThreadId, Environment.CurrentManagedThreadId); Assert.Same(this.ctorSyncContext, SynchronizationContext.Current); From b0c3d83b28e7679b7c962347dbcacf12794c7959 Mon Sep 17 00:00:00 2001 From: reduckted Date: Fri, 10 Jan 2025 22:21:21 +1000 Subject: [PATCH 10/27] Used `xunit.v3.extensibility.core` instead of `xunit.v3.core`. --- Directory.Packages.props | 2 +- src/Xunit.StaFact/Xunit.StaFact.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 0c9849d4..12b00b63 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -8,7 +8,7 @@ - + diff --git a/src/Xunit.StaFact/Xunit.StaFact.csproj b/src/Xunit.StaFact/Xunit.StaFact.csproj index 5985f924..12c7282b 100644 --- a/src/Xunit.StaFact/Xunit.StaFact.csproj +++ b/src/Xunit.StaFact/Xunit.StaFact.csproj @@ -37,6 +37,6 @@ Theory variants of these attributes allow for parameterized testing. Check out t - + From 04a1523516c6bb79925b470645f268caca9a43a2 Mon Sep 17 00:00:00 2001 From: reduckted Date: Fri, 10 Jan 2025 22:21:45 +1000 Subject: [PATCH 11/27] Fixed analyzer warnings. --- src/Xunit.StaFact/Sdk.Mac/CocoaTheoryDiscoverer.cs | 1 - src/Xunit.StaFact/Sdk/SkippedTestCase.cs | 3 +++ src/Xunit.StaFact/Sdk/Utilities.cs | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Xunit.StaFact/Sdk.Mac/CocoaTheoryDiscoverer.cs b/src/Xunit.StaFact/Sdk.Mac/CocoaTheoryDiscoverer.cs index 8e9c86fd..4ebec6f4 100644 --- a/src/Xunit.StaFact/Sdk.Mac/CocoaTheoryDiscoverer.cs +++ b/src/Xunit.StaFact/Sdk.Mac/CocoaTheoryDiscoverer.cs @@ -1,7 +1,6 @@ // Copyright (c) Andrew Arnott. All rights reserved. // Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. - namespace Xunit.Sdk; /// diff --git a/src/Xunit.StaFact/Sdk/SkippedTestCase.cs b/src/Xunit.StaFact/Sdk/SkippedTestCase.cs index 15e033bf..03505276 100644 --- a/src/Xunit.StaFact/Sdk/SkippedTestCase.cs +++ b/src/Xunit.StaFact/Sdk/SkippedTestCase.cs @@ -1,3 +1,6 @@ +// Copyright (c) Andrew Arnott. All rights reserved. +// Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. + using System.ComponentModel; namespace Xunit.Sdk; diff --git a/src/Xunit.StaFact/Sdk/Utilities.cs b/src/Xunit.StaFact/Sdk/Utilities.cs index bd606607..0c9872d4 100644 --- a/src/Xunit.StaFact/Sdk/Utilities.cs +++ b/src/Xunit.StaFact/Sdk/Utilities.cs @@ -76,6 +76,8 @@ internal static IXunitTestCase CreateTestCase( timeout: details.Timeout); } + internal static SyncContextAwaiter GetAwaiter(this SynchronizationContext synchronizationContext) => new SyncContextAwaiter(synchronizationContext); + private static UISettingsAttribute GetSettings(IXunitTestMethod testMethod) { // Initialize with defaults. @@ -103,8 +105,6 @@ private static IEnumerable GetSettingsAttributes(IXunitTest } } - internal static SyncContextAwaiter GetAwaiter(this SynchronizationContext synchronizationContext) => new SyncContextAwaiter(synchronizationContext); - internal struct SyncContextAwaiter : ICriticalNotifyCompletion { private readonly SynchronizationContext synchronizationContext; From 461feb907da7ef5228b16257be0ec19f562a71ac Mon Sep 17 00:00:00 2001 From: reduckted Date: Fri, 10 Jan 2025 22:23:20 +1000 Subject: [PATCH 12/27] Fixed compilation error in `CocoaSynchronizationContext`. --- src/Xunit.StaFact/Sdk.Mac/CocoaSynchronizationContext.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Xunit.StaFact/Sdk.Mac/CocoaSynchronizationContext.cs b/src/Xunit.StaFact/Sdk.Mac/CocoaSynchronizationContext.cs index 85290a59..28f4e3ed 100644 --- a/src/Xunit.StaFact/Sdk.Mac/CocoaSynchronizationContext.cs +++ b/src/Xunit.StaFact/Sdk.Mac/CocoaSynchronizationContext.cs @@ -1,4 +1,4 @@ -// Copyright (c) Andrew Arnott. All rights reserved. +// Copyright (c) Andrew Arnott. All rights reserved. // Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. namespace Xunit.Sdk; @@ -171,9 +171,9 @@ private bool TryOneWorkItem() try { - if (this.aggregator is object) + if (this.aggregator.HasValue) { - this.aggregator.Run(() => work.Key(work.Value)); + this.aggregator.Value.Run(() => work.Key(work.Value)); } else { From f41c7e40f9f336a2e122de89919001b79351e468 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 15 Jan 2025 19:03:03 -0700 Subject: [PATCH 13/27] Fix compiler warnings --- .../net472/PublicAPI.Shipped.txt | 82 ++++++++++++------- .../net8.0-macos14.0/PublicAPI.Unshipped.txt | 59 +++++++------ .../net8.0-windows/PublicAPI.Shipped.txt | 64 --------------- .../net8.0-windows/PublicAPI.Unshipped.txt | 71 ++++++++++++++++ .../net8.0/PublicAPI.Shipped.txt | 49 ++++++----- .../netstandard2.0/PublicAPI.Shipped.txt | 40 --------- .../netstandard2.0/PublicAPI.Unshipped.txt | 47 +++++++++++ 7 files changed, 230 insertions(+), 182 deletions(-) diff --git a/src/Xunit.StaFact/net472/PublicAPI.Shipped.txt b/src/Xunit.StaFact/net472/PublicAPI.Shipped.txt index 4f33aa3c..e9e062fc 100644 --- a/src/Xunit.StaFact/net472/PublicAPI.Shipped.txt +++ b/src/Xunit.StaFact/net472/PublicAPI.Shipped.txt @@ -1,29 +1,45 @@ #nullable enable -override Xunit.Sdk.StaFactDiscoverer.CreateTestCase(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! factAttribute) -> Xunit.Sdk.IXunitTestCase! -override Xunit.Sdk.StaTheoryDiscoverer.CreateTestCasesForDataRow(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! theoryAttribute, object![]! dataRow) -> System.Collections.Generic.IEnumerable! -override Xunit.Sdk.StaTheoryDiscoverer.CreateTestCasesForTheory(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! theoryAttribute) -> System.Collections.Generic.IEnumerable! -override Xunit.Sdk.UIFactDiscoverer.CreateTestCase(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! factAttribute) -> Xunit.Sdk.IXunitTestCase! -override Xunit.Sdk.UITestCase.Deserialize(Xunit.Abstractions.IXunitSerializationInfo! data) -> void -override Xunit.Sdk.UITestCase.RunAsync(Xunit.Abstractions.IMessageSink! diagnosticMessageSink, Xunit.Sdk.IMessageBus! messageBus, object![]! constructorArguments, Xunit.Sdk.ExceptionAggregator! aggregator, System.Threading.CancellationTokenSource! cancellationTokenSource) -> System.Threading.Tasks.Task! -override Xunit.Sdk.UITestCase.Serialize(Xunit.Abstractions.IXunitSerializationInfo! data) -> void -override Xunit.Sdk.UITheoryDiscoverer.CreateTestCasesForDataRow(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! theoryAttribute, object![]! dataRow) -> System.Collections.Generic.IEnumerable! -override Xunit.Sdk.UITheoryDiscoverer.CreateTestCasesForTheory(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! theoryAttribute) -> System.Collections.Generic.IEnumerable! -override Xunit.Sdk.UITheoryTestCase.Deserialize(Xunit.Abstractions.IXunitSerializationInfo! data) -> void -override Xunit.Sdk.UITheoryTestCase.RunAsync(Xunit.Abstractions.IMessageSink! diagnosticMessageSink, Xunit.Sdk.IMessageBus! messageBus, object![]! constructorArguments, Xunit.Sdk.ExceptionAggregator! aggregator, System.Threading.CancellationTokenSource! cancellationTokenSource) -> System.Threading.Tasks.Task! -override Xunit.Sdk.UITheoryTestCase.Serialize(Xunit.Abstractions.IXunitSerializationInfo! data) -> void -override Xunit.Sdk.WinFormsFactDiscoverer.CreateTestCase(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! factAttribute) -> Xunit.Sdk.IXunitTestCase! -override Xunit.Sdk.WinFormsTheoryDiscoverer.CreateTestCasesForDataRow(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! theoryAttribute, object![]! dataRow) -> System.Collections.Generic.IEnumerable! -override Xunit.Sdk.WinFormsTheoryDiscoverer.CreateTestCasesForTheory(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! theoryAttribute) -> System.Collections.Generic.IEnumerable! -override Xunit.Sdk.WpfFactDiscoverer.CreateTestCase(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! factAttribute) -> Xunit.Sdk.IXunitTestCase! -override Xunit.Sdk.WpfTheoryDiscoverer.CreateTestCasesForDataRow(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! theoryAttribute, object![]! dataRow) -> System.Collections.Generic.IEnumerable! -override Xunit.Sdk.WpfTheoryDiscoverer.CreateTestCasesForTheory(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! theoryAttribute) -> System.Collections.Generic.IEnumerable! +override Xunit.Sdk.StaFactDiscoverer.CreateTestCase(Xunit.Sdk.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.v3.IXunitTestMethod! testMethod, Xunit.v3.IFactAttribute! factAttribute) -> Xunit.v3.IXunitTestCase! +override Xunit.Sdk.StaTheoryDiscoverer.CreateTestCasesForDataRow(Xunit.Sdk.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.v3.IXunitTestMethod! testMethod, Xunit.v3.ITheoryAttribute! theoryAttribute, Xunit.ITheoryDataRow! dataRow, object?[]! testMethodArguments) -> System.Threading.Tasks.ValueTask!> +override Xunit.Sdk.StaTheoryDiscoverer.CreateTestCasesForTheory(Xunit.Sdk.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.v3.IXunitTestMethod! testMethod, Xunit.v3.ITheoryAttribute! theoryAttribute) -> System.Threading.Tasks.ValueTask!> +override Xunit.Sdk.UIDelayEnumeratedTestCase.Deserialize(Xunit.Sdk.IXunitSerializationInfo! data) -> void +override Xunit.Sdk.UIDelayEnumeratedTestCase.Serialize(Xunit.Sdk.IXunitSerializationInfo! data) -> void +override Xunit.Sdk.UIFactDiscoverer.CreateTestCase(Xunit.Sdk.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.v3.IXunitTestMethod! testMethod, Xunit.v3.IFactAttribute! factAttribute) -> Xunit.v3.IXunitTestCase! +override Xunit.Sdk.UITestCase.Deserialize(Xunit.Sdk.IXunitSerializationInfo! data) -> void +override Xunit.Sdk.UITestCase.Serialize(Xunit.Sdk.IXunitSerializationInfo! data) -> void +override Xunit.Sdk.UITestRunner.RunTest(Xunit.Sdk.UITestRunnerContext! ctxt) -> System.Threading.Tasks.ValueTask +override Xunit.Sdk.UITheoryDiscoverer.CreateTestCasesForDataRow(Xunit.Sdk.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.v3.IXunitTestMethod! testMethod, Xunit.v3.ITheoryAttribute! theoryAttribute, Xunit.ITheoryDataRow! dataRow, object?[]! testMethodArguments) -> System.Threading.Tasks.ValueTask!> +override Xunit.Sdk.UITheoryDiscoverer.CreateTestCasesForTheory(Xunit.Sdk.ITestFrameworkDiscoveryOptions discoveryOptions, Xunit.v3.IXunitTestMethod testMethod, Xunit.v3.ITheoryAttribute theoryAttribute) -> System.Threading.Tasks.ValueTask> +override Xunit.Sdk.UITheoryDiscoverer.CreateTestCasesForTheory(Xunit.Sdk.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.v3.IXunitTestMethod! testMethod, Xunit.v3.ITheoryAttribute! theoryAttribute) -> System.Threading.Tasks.ValueTask!> +override Xunit.Sdk.WinFormsFactDiscoverer.CreateTestCase(Xunit.Sdk.ITestFrameworkDiscoveryOptions discoveryOptions, Xunit.v3.IXunitTestMethod testMethod, Xunit.v3.IFactAttribute factAttribute) -> Xunit.v3.IXunitTestCase +override Xunit.Sdk.WinFormsFactDiscoverer.CreateTestCase(Xunit.Sdk.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.v3.IXunitTestMethod! testMethod, Xunit.v3.IFactAttribute! factAttribute) -> Xunit.v3.IXunitTestCase! +override Xunit.Sdk.WinFormsTheoryDiscoverer.CreateTestCasesForDataRow(Xunit.Sdk.ITestFrameworkDiscoveryOptions discoveryOptions, Xunit.v3.IXunitTestMethod testMethod, Xunit.v3.ITheoryAttribute theoryAttribute, Xunit.ITheoryDataRow dataRow, object[] testMethodArguments) -> System.Threading.Tasks.ValueTask> +override Xunit.Sdk.WinFormsTheoryDiscoverer.CreateTestCasesForDataRow(Xunit.Sdk.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.v3.IXunitTestMethod! testMethod, Xunit.v3.ITheoryAttribute! theoryAttribute, Xunit.ITheoryDataRow! dataRow, object?[]! testMethodArguments) -> System.Threading.Tasks.ValueTask!> +override Xunit.Sdk.WinFormsTheoryDiscoverer.CreateTestCasesForTheory(Xunit.Sdk.ITestFrameworkDiscoveryOptions discoveryOptions, Xunit.v3.IXunitTestMethod testMethod, Xunit.v3.ITheoryAttribute theoryAttribute) -> System.Threading.Tasks.ValueTask> +override Xunit.Sdk.WinFormsTheoryDiscoverer.CreateTestCasesForTheory(Xunit.Sdk.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.v3.IXunitTestMethod! testMethod, Xunit.v3.ITheoryAttribute! theoryAttribute) -> System.Threading.Tasks.ValueTask!> +override Xunit.Sdk.WpfFactDiscoverer.CreateTestCase(Xunit.Sdk.ITestFrameworkDiscoveryOptions discoveryOptions, Xunit.v3.IXunitTestMethod testMethod, Xunit.v3.IFactAttribute factAttribute) -> Xunit.v3.IXunitTestCase +override Xunit.Sdk.WpfFactDiscoverer.CreateTestCase(Xunit.Sdk.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.v3.IXunitTestMethod! testMethod, Xunit.v3.IFactAttribute! factAttribute) -> Xunit.v3.IXunitTestCase! +override Xunit.Sdk.WpfTheoryDiscoverer.CreateTestCasesForDataRow(Xunit.Sdk.ITestFrameworkDiscoveryOptions discoveryOptions, Xunit.v3.IXunitTestMethod testMethod, Xunit.v3.ITheoryAttribute theoryAttribute, Xunit.ITheoryDataRow dataRow, object[] testMethodArguments) -> System.Threading.Tasks.ValueTask> +override Xunit.Sdk.WpfTheoryDiscoverer.CreateTestCasesForDataRow(Xunit.Sdk.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.v3.IXunitTestMethod! testMethod, Xunit.v3.ITheoryAttribute! theoryAttribute, Xunit.ITheoryDataRow! dataRow, object?[]! testMethodArguments) -> System.Threading.Tasks.ValueTask!> +override Xunit.Sdk.WpfTheoryDiscoverer.CreateTestCasesForTheory(Xunit.Sdk.ITestFrameworkDiscoveryOptions discoveryOptions, Xunit.v3.IXunitTestMethod testMethod, Xunit.v3.ITheoryAttribute theoryAttribute) -> System.Threading.Tasks.ValueTask> +override Xunit.Sdk.WpfTheoryDiscoverer.CreateTestCasesForTheory(Xunit.Sdk.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.v3.IXunitTestMethod! testMethod, Xunit.v3.ITheoryAttribute! theoryAttribute) -> System.Threading.Tasks.ValueTask!> +static Xunit.Sdk.UITestRunner.Instance.get -> Xunit.Sdk.UITestRunner +static Xunit.Sdk.UITestRunner.Instance.get -> Xunit.Sdk.UITestRunner! +Xunit.Sdk.SkippedTestCase +Xunit.Sdk.SkippedTestCase.SkippedTestCase() -> void Xunit.Sdk.StaFactDiscoverer -Xunit.Sdk.StaFactDiscoverer.StaFactDiscoverer(Xunit.Abstractions.IMessageSink! diagnosticMessageSink) -> void +Xunit.Sdk.StaFactDiscoverer.StaFactDiscoverer() -> void Xunit.Sdk.StaTheoryDiscoverer -Xunit.Sdk.StaTheoryDiscoverer.StaTheoryDiscoverer(Xunit.Abstractions.IMessageSink! diagnosticMessageSink) -> void +Xunit.Sdk.StaTheoryDiscoverer.StaTheoryDiscoverer() -> void +Xunit.Sdk.UIDelayEnumeratedTestCase +Xunit.Sdk.UIDelayEnumeratedTestCase.Run(Xunit.Sdk.ExplicitOption explicitOption, Xunit.v3.IMessageBus messageBus, object[] constructorArguments, Xunit.v3.ExceptionAggregator aggregator, System.Threading.CancellationTokenSource cancellationTokenSource) -> System.Threading.Tasks.ValueTask +Xunit.Sdk.UIDelayEnumeratedTestCase.Run(Xunit.Sdk.ExplicitOption explicitOption, Xunit.v3.IMessageBus! messageBus, object?[]! constructorArguments, Xunit.v3.ExceptionAggregator aggregator, System.Threading.CancellationTokenSource! cancellationTokenSource) -> System.Threading.Tasks.ValueTask +Xunit.Sdk.UIDelayEnumeratedTestCase.UIDelayEnumeratedTestCase() -> void Xunit.Sdk.UIFactDiscoverer -Xunit.Sdk.UIFactDiscoverer.UIFactDiscoverer(Xunit.Abstractions.IMessageSink! diagnosticMessageSink) -> void +Xunit.Sdk.UIFactDiscoverer.UIFactDiscoverer() -> void Xunit.Sdk.UITestCase +Xunit.Sdk.UITestCase.Run(Xunit.Sdk.ExplicitOption explicitOption, Xunit.v3.IMessageBus messageBus, object[] constructorArguments, Xunit.v3.ExceptionAggregator aggregator, System.Threading.CancellationTokenSource cancellationTokenSource) -> System.Threading.Tasks.ValueTask +Xunit.Sdk.UITestCase.Run(Xunit.Sdk.ExplicitOption explicitOption, Xunit.v3.IMessageBus! messageBus, object?[]! constructorArguments, Xunit.v3.ExceptionAggregator aggregator, System.Threading.CancellationTokenSource! cancellationTokenSource) -> System.Threading.Tasks.ValueTask Xunit.Sdk.UITestCase.SyncContextType Xunit.Sdk.UITestCase.SyncContextType.None = 0 -> Xunit.Sdk.UITestCase.SyncContextType Xunit.Sdk.UITestCase.SyncContextType.Portable = 1 -> Xunit.Sdk.UITestCase.SyncContextType @@ -31,22 +47,26 @@ Xunit.Sdk.UITestCase.SyncContextType.WinForms = 3 -> Xunit.Sdk.UITestCase.SyncCo Xunit.Sdk.UITestCase.SyncContextType.WPF = 2 -> Xunit.Sdk.UITestCase.SyncContextType Xunit.Sdk.UITestCase.UITestCase() -> void Xunit.Sdk.UITestCaseRunner -Xunit.Sdk.UITestInvoker -Xunit.Sdk.UITestInvoker.RunAsync() -> System.Threading.Tasks.Task! +Xunit.Sdk.UITestCaseRunner.Run(Xunit.v3.IXunitTestCase testCase, Xunit.v3.IMessageBus messageBus, Xunit.v3.ExceptionAggregator aggregator, System.Threading.CancellationTokenSource cancellationTokenSource, string displayName, string skipReason, Xunit.Sdk.ExplicitOption explicitOption, object[] constructorArguments) -> System.Threading.Tasks.ValueTask +Xunit.Sdk.UITestCaseRunner.Run(Xunit.v3.IXunitTestCase! testCase, Xunit.v3.IMessageBus! messageBus, Xunit.v3.ExceptionAggregator aggregator, System.Threading.CancellationTokenSource! cancellationTokenSource, string! displayName, string? skipReason, Xunit.Sdk.ExplicitOption explicitOption, object?[]! constructorArguments) -> System.Threading.Tasks.ValueTask +Xunit.Sdk.UITestCaseRunnerContext +Xunit.Sdk.UITestCaseRunnerContext.Settings.get -> Xunit.UISettingsAttribute +Xunit.Sdk.UITestCaseRunnerContext.Settings.get -> Xunit.UISettingsAttribute! Xunit.Sdk.UITestRunner +Xunit.Sdk.UITestRunner.UITestRunner() -> void +Xunit.Sdk.UITestRunnerContext +Xunit.Sdk.UITestRunnerContext.Settings.get -> Xunit.UISettingsAttribute +Xunit.Sdk.UITestRunnerContext.Settings.get -> Xunit.UISettingsAttribute! Xunit.Sdk.UITheoryDiscoverer -Xunit.Sdk.UITheoryDiscoverer.UITheoryDiscoverer(Xunit.Abstractions.IMessageSink! diagnosticMessageSink) -> void -Xunit.Sdk.UITheoryTestCase -Xunit.Sdk.UITheoryTestCase.UITheoryTestCase() -> void -Xunit.Sdk.UITheoryTestCaseRunner +Xunit.Sdk.UITheoryDiscoverer.UITheoryDiscoverer() -> void Xunit.Sdk.WinFormsFactDiscoverer -Xunit.Sdk.WinFormsFactDiscoverer.WinFormsFactDiscoverer(Xunit.Abstractions.IMessageSink! diagnosticMessageSink) -> void +Xunit.Sdk.WinFormsFactDiscoverer.WinFormsFactDiscoverer() -> void Xunit.Sdk.WinFormsTheoryDiscoverer -Xunit.Sdk.WinFormsTheoryDiscoverer.WinFormsTheoryDiscoverer(Xunit.Abstractions.IMessageSink! diagnosticMessageSink) -> void +Xunit.Sdk.WinFormsTheoryDiscoverer.WinFormsTheoryDiscoverer() -> void Xunit.Sdk.WpfFactDiscoverer -Xunit.Sdk.WpfFactDiscoverer.WpfFactDiscoverer(Xunit.Abstractions.IMessageSink! diagnosticMessageSink) -> void +Xunit.Sdk.WpfFactDiscoverer.WpfFactDiscoverer() -> void Xunit.Sdk.WpfTheoryDiscoverer -Xunit.Sdk.WpfTheoryDiscoverer.WpfTheoryDiscoverer(Xunit.Abstractions.IMessageSink! diagnosticMessageSink) -> void +Xunit.Sdk.WpfTheoryDiscoverer.WpfTheoryDiscoverer() -> void Xunit.StaFactAttribute Xunit.StaFactAttribute.StaFactAttribute() -> void Xunit.StaTheoryAttribute diff --git a/src/Xunit.StaFact/net8.0-macos14.0/PublicAPI.Unshipped.txt b/src/Xunit.StaFact/net8.0-macos14.0/PublicAPI.Unshipped.txt index a6b7fc2d..974f721d 100644 --- a/src/Xunit.StaFact/net8.0-macos14.0/PublicAPI.Unshipped.txt +++ b/src/Xunit.StaFact/net8.0-macos14.0/PublicAPI.Unshipped.txt @@ -1,48 +1,55 @@ #nullable enable -override Xunit.Sdk.CocoaFactDiscoverer.CreateTestCase(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! factAttribute) -> Xunit.Sdk.IXunitTestCase! -override Xunit.Sdk.CocoaTheoryDiscoverer.CreateTestCasesForDataRow(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! theoryAttribute, object![]! dataRow) -> System.Collections.Generic.IEnumerable! -override Xunit.Sdk.CocoaTheoryDiscoverer.CreateTestCasesForTheory(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! theoryAttribute) -> System.Collections.Generic.IEnumerable! -override Xunit.Sdk.StaFactDiscoverer.CreateTestCase(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! factAttribute) -> Xunit.Sdk.IXunitTestCase! -override Xunit.Sdk.StaTheoryDiscoverer.CreateTestCasesForDataRow(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! theoryAttribute, object![]! dataRow) -> System.Collections.Generic.IEnumerable! -override Xunit.Sdk.StaTheoryDiscoverer.CreateTestCasesForTheory(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! theoryAttribute) -> System.Collections.Generic.IEnumerable! -override Xunit.Sdk.UIFactDiscoverer.CreateTestCase(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! factAttribute) -> Xunit.Sdk.IXunitTestCase! -override Xunit.Sdk.UITestCase.Deserialize(Xunit.Abstractions.IXunitSerializationInfo! data) -> void -override Xunit.Sdk.UITestCase.RunAsync(Xunit.Abstractions.IMessageSink! diagnosticMessageSink, Xunit.Sdk.IMessageBus! messageBus, object![]! constructorArguments, Xunit.Sdk.ExceptionAggregator! aggregator, System.Threading.CancellationTokenSource! cancellationTokenSource) -> System.Threading.Tasks.Task! -override Xunit.Sdk.UITestCase.Serialize(Xunit.Abstractions.IXunitSerializationInfo! data) -> void -override Xunit.Sdk.UITheoryDiscoverer.CreateTestCasesForDataRow(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! theoryAttribute, object![]! dataRow) -> System.Collections.Generic.IEnumerable! -override Xunit.Sdk.UITheoryDiscoverer.CreateTestCasesForTheory(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! theoryAttribute) -> System.Collections.Generic.IEnumerable! -override Xunit.Sdk.UITheoryTestCase.Deserialize(Xunit.Abstractions.IXunitSerializationInfo! data) -> void -override Xunit.Sdk.UITheoryTestCase.RunAsync(Xunit.Abstractions.IMessageSink! diagnosticMessageSink, Xunit.Sdk.IMessageBus! messageBus, object![]! constructorArguments, Xunit.Sdk.ExceptionAggregator! aggregator, System.Threading.CancellationTokenSource! cancellationTokenSource) -> System.Threading.Tasks.Task! -override Xunit.Sdk.UITheoryTestCase.Serialize(Xunit.Abstractions.IXunitSerializationInfo! data) -> void +override Xunit.Sdk.CocoaFactDiscoverer.CreateTestCase(Xunit.Sdk.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.v3.IXunitTestMethod! testMethod, Xunit.v3.IFactAttribute! factAttribute) -> Xunit.v3.IXunitTestCase! +override Xunit.Sdk.CocoaTheoryDiscoverer.CreateTestCasesForDataRow(Xunit.Sdk.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.v3.IXunitTestMethod! testMethod, Xunit.v3.ITheoryAttribute! theoryAttribute, Xunit.ITheoryDataRow! dataRow, object?[]! testMethodArguments) -> System.Threading.Tasks.ValueTask!> +override Xunit.Sdk.CocoaTheoryDiscoverer.CreateTestCasesForTheory(Xunit.Sdk.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.v3.IXunitTestMethod! testMethod, Xunit.v3.ITheoryAttribute! theoryAttribute) -> System.Threading.Tasks.ValueTask!> +override Xunit.Sdk.StaFactDiscoverer.CreateTestCase(Xunit.Sdk.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.v3.IXunitTestMethod! testMethod, Xunit.v3.IFactAttribute! factAttribute) -> Xunit.v3.IXunitTestCase! +override Xunit.Sdk.StaTheoryDiscoverer.CreateTestCasesForDataRow(Xunit.Sdk.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.v3.IXunitTestMethod! testMethod, Xunit.v3.ITheoryAttribute! theoryAttribute, Xunit.ITheoryDataRow! dataRow, object?[]! testMethodArguments) -> System.Threading.Tasks.ValueTask!> +override Xunit.Sdk.StaTheoryDiscoverer.CreateTestCasesForTheory(Xunit.Sdk.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.v3.IXunitTestMethod! testMethod, Xunit.v3.ITheoryAttribute! theoryAttribute) -> System.Threading.Tasks.ValueTask!> +override Xunit.Sdk.UIDelayEnumeratedTestCase.Deserialize(Xunit.Sdk.IXunitSerializationInfo! data) -> void +override Xunit.Sdk.UIDelayEnumeratedTestCase.Serialize(Xunit.Sdk.IXunitSerializationInfo! data) -> void +override Xunit.Sdk.UIFactDiscoverer.CreateTestCase(Xunit.Sdk.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.v3.IXunitTestMethod! testMethod, Xunit.v3.IFactAttribute! factAttribute) -> Xunit.v3.IXunitTestCase! +override Xunit.Sdk.UITestCase.Deserialize(Xunit.Sdk.IXunitSerializationInfo! data) -> void +override Xunit.Sdk.UITestCase.Serialize(Xunit.Sdk.IXunitSerializationInfo! data) -> void +override Xunit.Sdk.UITestRunner.RunTest(Xunit.Sdk.UITestRunnerContext! ctxt) -> System.Threading.Tasks.ValueTask +override Xunit.Sdk.UITheoryDiscoverer.CreateTestCasesForDataRow(Xunit.Sdk.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.v3.IXunitTestMethod! testMethod, Xunit.v3.ITheoryAttribute! theoryAttribute, Xunit.ITheoryDataRow! dataRow, object?[]! testMethodArguments) -> System.Threading.Tasks.ValueTask!> +override Xunit.Sdk.UITheoryDiscoverer.CreateTestCasesForTheory(Xunit.Sdk.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.v3.IXunitTestMethod! testMethod, Xunit.v3.ITheoryAttribute! theoryAttribute) -> System.Threading.Tasks.ValueTask!> +static Xunit.Sdk.UITestRunner.Instance.get -> Xunit.Sdk.UITestRunner! Xunit.CocoaFactAttribute Xunit.CocoaFactAttribute.CocoaFactAttribute() -> void Xunit.CocoaTheoryAttribute Xunit.CocoaTheoryAttribute.CocoaTheoryAttribute() -> void Xunit.Sdk.CocoaFactDiscoverer -Xunit.Sdk.CocoaFactDiscoverer.CocoaFactDiscoverer(Xunit.Abstractions.IMessageSink! diagnosticMessageSink) -> void +Xunit.Sdk.CocoaFactDiscoverer.CocoaFactDiscoverer() -> void Xunit.Sdk.CocoaTheoryDiscoverer -Xunit.Sdk.CocoaTheoryDiscoverer.CocoaTheoryDiscoverer(Xunit.Abstractions.IMessageSink! diagnosticMessageSink) -> void +Xunit.Sdk.CocoaTheoryDiscoverer.CocoaTheoryDiscoverer() -> void +Xunit.Sdk.SkippedTestCase +Xunit.Sdk.SkippedTestCase.SkippedTestCase() -> void Xunit.Sdk.StaFactDiscoverer -Xunit.Sdk.StaFactDiscoverer.StaFactDiscoverer(Xunit.Abstractions.IMessageSink! diagnosticMessageSink) -> void +Xunit.Sdk.StaFactDiscoverer.StaFactDiscoverer() -> void Xunit.Sdk.StaTheoryDiscoverer -Xunit.Sdk.StaTheoryDiscoverer.StaTheoryDiscoverer(Xunit.Abstractions.IMessageSink! diagnosticMessageSink) -> void +Xunit.Sdk.StaTheoryDiscoverer.StaTheoryDiscoverer() -> void +Xunit.Sdk.UIDelayEnumeratedTestCase +Xunit.Sdk.UIDelayEnumeratedTestCase.Run(Xunit.Sdk.ExplicitOption explicitOption, Xunit.v3.IMessageBus! messageBus, object?[]! constructorArguments, Xunit.v3.ExceptionAggregator aggregator, System.Threading.CancellationTokenSource! cancellationTokenSource) -> System.Threading.Tasks.ValueTask +Xunit.Sdk.UIDelayEnumeratedTestCase.UIDelayEnumeratedTestCase() -> void Xunit.Sdk.UIFactDiscoverer -Xunit.Sdk.UIFactDiscoverer.UIFactDiscoverer(Xunit.Abstractions.IMessageSink! diagnosticMessageSink) -> void +Xunit.Sdk.UIFactDiscoverer.UIFactDiscoverer() -> void Xunit.Sdk.UITestCase +Xunit.Sdk.UITestCase.Run(Xunit.Sdk.ExplicitOption explicitOption, Xunit.v3.IMessageBus! messageBus, object?[]! constructorArguments, Xunit.v3.ExceptionAggregator aggregator, System.Threading.CancellationTokenSource! cancellationTokenSource) -> System.Threading.Tasks.ValueTask Xunit.Sdk.UITestCase.SyncContextType Xunit.Sdk.UITestCase.SyncContextType.Cocoa = 2 -> Xunit.Sdk.UITestCase.SyncContextType Xunit.Sdk.UITestCase.SyncContextType.None = 0 -> Xunit.Sdk.UITestCase.SyncContextType Xunit.Sdk.UITestCase.SyncContextType.Portable = 1 -> Xunit.Sdk.UITestCase.SyncContextType Xunit.Sdk.UITestCase.UITestCase() -> void Xunit.Sdk.UITestCaseRunner -Xunit.Sdk.UITestInvoker -Xunit.Sdk.UITestInvoker.RunAsync() -> System.Threading.Tasks.Task! +Xunit.Sdk.UITestCaseRunner.Run(Xunit.v3.IXunitTestCase! testCase, Xunit.v3.IMessageBus! messageBus, Xunit.v3.ExceptionAggregator aggregator, System.Threading.CancellationTokenSource! cancellationTokenSource, string! displayName, string? skipReason, Xunit.Sdk.ExplicitOption explicitOption, object?[]! constructorArguments) -> System.Threading.Tasks.ValueTask +Xunit.Sdk.UITestCaseRunnerContext +Xunit.Sdk.UITestCaseRunnerContext.Settings.get -> Xunit.UISettingsAttribute! Xunit.Sdk.UITestRunner +Xunit.Sdk.UITestRunner.UITestRunner() -> void +Xunit.Sdk.UITestRunnerContext +Xunit.Sdk.UITestRunnerContext.Settings.get -> Xunit.UISettingsAttribute! Xunit.Sdk.UITheoryDiscoverer -Xunit.Sdk.UITheoryDiscoverer.UITheoryDiscoverer(Xunit.Abstractions.IMessageSink! diagnosticMessageSink) -> void -Xunit.Sdk.UITheoryTestCase -Xunit.Sdk.UITheoryTestCase.UITheoryTestCase() -> void -Xunit.Sdk.UITheoryTestCaseRunner +Xunit.Sdk.UITheoryDiscoverer.UITheoryDiscoverer() -> void Xunit.StaFactAttribute Xunit.StaFactAttribute.StaFactAttribute() -> void Xunit.StaTheoryAttribute diff --git a/src/Xunit.StaFact/net8.0-windows/PublicAPI.Shipped.txt b/src/Xunit.StaFact/net8.0-windows/PublicAPI.Shipped.txt index 4f33aa3c..7dc5c581 100644 --- a/src/Xunit.StaFact/net8.0-windows/PublicAPI.Shipped.txt +++ b/src/Xunit.StaFact/net8.0-windows/PublicAPI.Shipped.txt @@ -1,65 +1 @@ #nullable enable -override Xunit.Sdk.StaFactDiscoverer.CreateTestCase(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! factAttribute) -> Xunit.Sdk.IXunitTestCase! -override Xunit.Sdk.StaTheoryDiscoverer.CreateTestCasesForDataRow(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! theoryAttribute, object![]! dataRow) -> System.Collections.Generic.IEnumerable! -override Xunit.Sdk.StaTheoryDiscoverer.CreateTestCasesForTheory(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! theoryAttribute) -> System.Collections.Generic.IEnumerable! -override Xunit.Sdk.UIFactDiscoverer.CreateTestCase(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! factAttribute) -> Xunit.Sdk.IXunitTestCase! -override Xunit.Sdk.UITestCase.Deserialize(Xunit.Abstractions.IXunitSerializationInfo! data) -> void -override Xunit.Sdk.UITestCase.RunAsync(Xunit.Abstractions.IMessageSink! diagnosticMessageSink, Xunit.Sdk.IMessageBus! messageBus, object![]! constructorArguments, Xunit.Sdk.ExceptionAggregator! aggregator, System.Threading.CancellationTokenSource! cancellationTokenSource) -> System.Threading.Tasks.Task! -override Xunit.Sdk.UITestCase.Serialize(Xunit.Abstractions.IXunitSerializationInfo! data) -> void -override Xunit.Sdk.UITheoryDiscoverer.CreateTestCasesForDataRow(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! theoryAttribute, object![]! dataRow) -> System.Collections.Generic.IEnumerable! -override Xunit.Sdk.UITheoryDiscoverer.CreateTestCasesForTheory(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! theoryAttribute) -> System.Collections.Generic.IEnumerable! -override Xunit.Sdk.UITheoryTestCase.Deserialize(Xunit.Abstractions.IXunitSerializationInfo! data) -> void -override Xunit.Sdk.UITheoryTestCase.RunAsync(Xunit.Abstractions.IMessageSink! diagnosticMessageSink, Xunit.Sdk.IMessageBus! messageBus, object![]! constructorArguments, Xunit.Sdk.ExceptionAggregator! aggregator, System.Threading.CancellationTokenSource! cancellationTokenSource) -> System.Threading.Tasks.Task! -override Xunit.Sdk.UITheoryTestCase.Serialize(Xunit.Abstractions.IXunitSerializationInfo! data) -> void -override Xunit.Sdk.WinFormsFactDiscoverer.CreateTestCase(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! factAttribute) -> Xunit.Sdk.IXunitTestCase! -override Xunit.Sdk.WinFormsTheoryDiscoverer.CreateTestCasesForDataRow(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! theoryAttribute, object![]! dataRow) -> System.Collections.Generic.IEnumerable! -override Xunit.Sdk.WinFormsTheoryDiscoverer.CreateTestCasesForTheory(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! theoryAttribute) -> System.Collections.Generic.IEnumerable! -override Xunit.Sdk.WpfFactDiscoverer.CreateTestCase(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! factAttribute) -> Xunit.Sdk.IXunitTestCase! -override Xunit.Sdk.WpfTheoryDiscoverer.CreateTestCasesForDataRow(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! theoryAttribute, object![]! dataRow) -> System.Collections.Generic.IEnumerable! -override Xunit.Sdk.WpfTheoryDiscoverer.CreateTestCasesForTheory(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! theoryAttribute) -> System.Collections.Generic.IEnumerable! -Xunit.Sdk.StaFactDiscoverer -Xunit.Sdk.StaFactDiscoverer.StaFactDiscoverer(Xunit.Abstractions.IMessageSink! diagnosticMessageSink) -> void -Xunit.Sdk.StaTheoryDiscoverer -Xunit.Sdk.StaTheoryDiscoverer.StaTheoryDiscoverer(Xunit.Abstractions.IMessageSink! diagnosticMessageSink) -> void -Xunit.Sdk.UIFactDiscoverer -Xunit.Sdk.UIFactDiscoverer.UIFactDiscoverer(Xunit.Abstractions.IMessageSink! diagnosticMessageSink) -> void -Xunit.Sdk.UITestCase -Xunit.Sdk.UITestCase.SyncContextType -Xunit.Sdk.UITestCase.SyncContextType.None = 0 -> Xunit.Sdk.UITestCase.SyncContextType -Xunit.Sdk.UITestCase.SyncContextType.Portable = 1 -> Xunit.Sdk.UITestCase.SyncContextType -Xunit.Sdk.UITestCase.SyncContextType.WinForms = 3 -> Xunit.Sdk.UITestCase.SyncContextType -Xunit.Sdk.UITestCase.SyncContextType.WPF = 2 -> Xunit.Sdk.UITestCase.SyncContextType -Xunit.Sdk.UITestCase.UITestCase() -> void -Xunit.Sdk.UITestCaseRunner -Xunit.Sdk.UITestInvoker -Xunit.Sdk.UITestInvoker.RunAsync() -> System.Threading.Tasks.Task! -Xunit.Sdk.UITestRunner -Xunit.Sdk.UITheoryDiscoverer -Xunit.Sdk.UITheoryDiscoverer.UITheoryDiscoverer(Xunit.Abstractions.IMessageSink! diagnosticMessageSink) -> void -Xunit.Sdk.UITheoryTestCase -Xunit.Sdk.UITheoryTestCase.UITheoryTestCase() -> void -Xunit.Sdk.UITheoryTestCaseRunner -Xunit.Sdk.WinFormsFactDiscoverer -Xunit.Sdk.WinFormsFactDiscoverer.WinFormsFactDiscoverer(Xunit.Abstractions.IMessageSink! diagnosticMessageSink) -> void -Xunit.Sdk.WinFormsTheoryDiscoverer -Xunit.Sdk.WinFormsTheoryDiscoverer.WinFormsTheoryDiscoverer(Xunit.Abstractions.IMessageSink! diagnosticMessageSink) -> void -Xunit.Sdk.WpfFactDiscoverer -Xunit.Sdk.WpfFactDiscoverer.WpfFactDiscoverer(Xunit.Abstractions.IMessageSink! diagnosticMessageSink) -> void -Xunit.Sdk.WpfTheoryDiscoverer -Xunit.Sdk.WpfTheoryDiscoverer.WpfTheoryDiscoverer(Xunit.Abstractions.IMessageSink! diagnosticMessageSink) -> void -Xunit.StaFactAttribute -Xunit.StaFactAttribute.StaFactAttribute() -> void -Xunit.StaTheoryAttribute -Xunit.StaTheoryAttribute.StaTheoryAttribute() -> void -Xunit.UIFactAttribute -Xunit.UIFactAttribute.UIFactAttribute() -> void -Xunit.UITheoryAttribute -Xunit.UITheoryAttribute.UITheoryAttribute() -> void -Xunit.WinFormsFactAttribute -Xunit.WinFormsFactAttribute.WinFormsFactAttribute() -> void -Xunit.WinFormsTheoryAttribute -Xunit.WinFormsTheoryAttribute.WinFormsTheoryAttribute() -> void -Xunit.WpfFactAttribute -Xunit.WpfFactAttribute.WpfFactAttribute() -> void -Xunit.WpfTheoryAttribute -Xunit.WpfTheoryAttribute.WpfTheoryAttribute() -> void diff --git a/src/Xunit.StaFact/net8.0-windows/PublicAPI.Unshipped.txt b/src/Xunit.StaFact/net8.0-windows/PublicAPI.Unshipped.txt index 332ae6fc..680cc24f 100644 --- a/src/Xunit.StaFact/net8.0-windows/PublicAPI.Unshipped.txt +++ b/src/Xunit.StaFact/net8.0-windows/PublicAPI.Unshipped.txt @@ -1,4 +1,75 @@ +override Xunit.Sdk.StaFactDiscoverer.CreateTestCase(Xunit.Sdk.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.v3.IXunitTestMethod! testMethod, Xunit.v3.IFactAttribute! factAttribute) -> Xunit.v3.IXunitTestCase! +override Xunit.Sdk.StaTheoryDiscoverer.CreateTestCasesForDataRow(Xunit.Sdk.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.v3.IXunitTestMethod! testMethod, Xunit.v3.ITheoryAttribute! theoryAttribute, Xunit.ITheoryDataRow! dataRow, object?[]! testMethodArguments) -> System.Threading.Tasks.ValueTask!> +override Xunit.Sdk.StaTheoryDiscoverer.CreateTestCasesForTheory(Xunit.Sdk.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.v3.IXunitTestMethod! testMethod, Xunit.v3.ITheoryAttribute! theoryAttribute) -> System.Threading.Tasks.ValueTask!> +override Xunit.Sdk.UIDelayEnumeratedTestCase.Deserialize(Xunit.Sdk.IXunitSerializationInfo! data) -> void +override Xunit.Sdk.UIDelayEnumeratedTestCase.Serialize(Xunit.Sdk.IXunitSerializationInfo! data) -> void +override Xunit.Sdk.UIFactDiscoverer.CreateTestCase(Xunit.Sdk.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.v3.IXunitTestMethod! testMethod, Xunit.v3.IFactAttribute! factAttribute) -> Xunit.v3.IXunitTestCase! +override Xunit.Sdk.UITestCase.Deserialize(Xunit.Sdk.IXunitSerializationInfo! data) -> void +override Xunit.Sdk.UITestCase.Serialize(Xunit.Sdk.IXunitSerializationInfo! data) -> void +override Xunit.Sdk.UITestRunner.RunTest(Xunit.Sdk.UITestRunnerContext! ctxt) -> System.Threading.Tasks.ValueTask +override Xunit.Sdk.UITheoryDiscoverer.CreateTestCasesForDataRow(Xunit.Sdk.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.v3.IXunitTestMethod! testMethod, Xunit.v3.ITheoryAttribute! theoryAttribute, Xunit.ITheoryDataRow! dataRow, object?[]! testMethodArguments) -> System.Threading.Tasks.ValueTask!> +override Xunit.Sdk.UITheoryDiscoverer.CreateTestCasesForTheory(Xunit.Sdk.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.v3.IXunitTestMethod! testMethod, Xunit.v3.ITheoryAttribute! theoryAttribute) -> System.Threading.Tasks.ValueTask!> +override Xunit.Sdk.WinFormsFactDiscoverer.CreateTestCase(Xunit.Sdk.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.v3.IXunitTestMethod! testMethod, Xunit.v3.IFactAttribute! factAttribute) -> Xunit.v3.IXunitTestCase! +override Xunit.Sdk.WinFormsTheoryDiscoverer.CreateTestCasesForDataRow(Xunit.Sdk.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.v3.IXunitTestMethod! testMethod, Xunit.v3.ITheoryAttribute! theoryAttribute, Xunit.ITheoryDataRow! dataRow, object?[]! testMethodArguments) -> System.Threading.Tasks.ValueTask!> +override Xunit.Sdk.WinFormsTheoryDiscoverer.CreateTestCasesForTheory(Xunit.Sdk.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.v3.IXunitTestMethod! testMethod, Xunit.v3.ITheoryAttribute! theoryAttribute) -> System.Threading.Tasks.ValueTask!> +override Xunit.Sdk.WpfFactDiscoverer.CreateTestCase(Xunit.Sdk.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.v3.IXunitTestMethod! testMethod, Xunit.v3.IFactAttribute! factAttribute) -> Xunit.v3.IXunitTestCase! +override Xunit.Sdk.WpfTheoryDiscoverer.CreateTestCasesForDataRow(Xunit.Sdk.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.v3.IXunitTestMethod! testMethod, Xunit.v3.ITheoryAttribute! theoryAttribute, Xunit.ITheoryDataRow! dataRow, object?[]! testMethodArguments) -> System.Threading.Tasks.ValueTask!> +override Xunit.Sdk.WpfTheoryDiscoverer.CreateTestCasesForTheory(Xunit.Sdk.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.v3.IXunitTestMethod! testMethod, Xunit.v3.ITheoryAttribute! theoryAttribute) -> System.Threading.Tasks.ValueTask!> +static Xunit.Sdk.UITestRunner.Instance.get -> Xunit.Sdk.UITestRunner! +Xunit.Sdk.SkippedTestCase +Xunit.Sdk.SkippedTestCase.SkippedTestCase() -> void +Xunit.Sdk.StaFactDiscoverer +Xunit.Sdk.StaFactDiscoverer.StaFactDiscoverer() -> void +Xunit.Sdk.StaTheoryDiscoverer +Xunit.Sdk.StaTheoryDiscoverer.StaTheoryDiscoverer() -> void +Xunit.Sdk.UIDelayEnumeratedTestCase +Xunit.Sdk.UIDelayEnumeratedTestCase.Run(Xunit.Sdk.ExplicitOption explicitOption, Xunit.v3.IMessageBus! messageBus, object?[]! constructorArguments, Xunit.v3.ExceptionAggregator aggregator, System.Threading.CancellationTokenSource! cancellationTokenSource) -> System.Threading.Tasks.ValueTask +Xunit.Sdk.UIDelayEnumeratedTestCase.UIDelayEnumeratedTestCase() -> void +Xunit.Sdk.UIFactDiscoverer +Xunit.Sdk.UIFactDiscoverer.UIFactDiscoverer() -> void +Xunit.Sdk.UITestCase +Xunit.Sdk.UITestCase.Run(Xunit.Sdk.ExplicitOption explicitOption, Xunit.v3.IMessageBus! messageBus, object?[]! constructorArguments, Xunit.v3.ExceptionAggregator aggregator, System.Threading.CancellationTokenSource! cancellationTokenSource) -> System.Threading.Tasks.ValueTask +Xunit.Sdk.UITestCase.SyncContextType +Xunit.Sdk.UITestCase.SyncContextType.None = 0 -> Xunit.Sdk.UITestCase.SyncContextType +Xunit.Sdk.UITestCase.SyncContextType.Portable = 1 -> Xunit.Sdk.UITestCase.SyncContextType +Xunit.Sdk.UITestCase.SyncContextType.WinForms = 3 -> Xunit.Sdk.UITestCase.SyncContextType +Xunit.Sdk.UITestCase.SyncContextType.WPF = 2 -> Xunit.Sdk.UITestCase.SyncContextType +Xunit.Sdk.UITestCase.UITestCase() -> void +Xunit.Sdk.UITestCaseRunner +Xunit.Sdk.UITestCaseRunner.Run(Xunit.v3.IXunitTestCase! testCase, Xunit.v3.IMessageBus! messageBus, Xunit.v3.ExceptionAggregator aggregator, System.Threading.CancellationTokenSource! cancellationTokenSource, string! displayName, string? skipReason, Xunit.Sdk.ExplicitOption explicitOption, object?[]! constructorArguments) -> System.Threading.Tasks.ValueTask +Xunit.Sdk.UITestCaseRunnerContext +Xunit.Sdk.UITestCaseRunnerContext.Settings.get -> Xunit.UISettingsAttribute! +Xunit.Sdk.UITestRunner +Xunit.Sdk.UITestRunner.UITestRunner() -> void +Xunit.Sdk.UITestRunnerContext +Xunit.Sdk.UITestRunnerContext.Settings.get -> Xunit.UISettingsAttribute! +Xunit.Sdk.UITheoryDiscoverer +Xunit.Sdk.UITheoryDiscoverer.UITheoryDiscoverer() -> void +Xunit.Sdk.WinFormsFactDiscoverer +Xunit.Sdk.WinFormsFactDiscoverer.WinFormsFactDiscoverer() -> void +Xunit.Sdk.WinFormsTheoryDiscoverer +Xunit.Sdk.WinFormsTheoryDiscoverer.WinFormsTheoryDiscoverer() -> void +Xunit.Sdk.WpfFactDiscoverer +Xunit.Sdk.WpfFactDiscoverer.WpfFactDiscoverer() -> void +Xunit.Sdk.WpfTheoryDiscoverer +Xunit.Sdk.WpfTheoryDiscoverer.WpfTheoryDiscoverer() -> void +Xunit.StaFactAttribute +Xunit.StaFactAttribute.StaFactAttribute() -> void +Xunit.StaTheoryAttribute +Xunit.StaTheoryAttribute.StaTheoryAttribute() -> void +Xunit.UIFactAttribute +Xunit.UIFactAttribute.UIFactAttribute() -> void Xunit.UISettingsAttribute Xunit.UISettingsAttribute.MaxAttempts.get -> int Xunit.UISettingsAttribute.MaxAttempts.set -> void Xunit.UISettingsAttribute.UISettingsAttribute() -> void +Xunit.UITheoryAttribute +Xunit.UITheoryAttribute.UITheoryAttribute() -> void +Xunit.WinFormsFactAttribute +Xunit.WinFormsFactAttribute.WinFormsFactAttribute() -> void +Xunit.WinFormsTheoryAttribute +Xunit.WinFormsTheoryAttribute.WinFormsTheoryAttribute() -> void +Xunit.WpfFactAttribute +Xunit.WpfFactAttribute.WpfFactAttribute() -> void +Xunit.WpfTheoryAttribute +Xunit.WpfTheoryAttribute.WpfTheoryAttribute() -> void \ No newline at end of file diff --git a/src/Xunit.StaFact/net8.0/PublicAPI.Shipped.txt b/src/Xunit.StaFact/net8.0/PublicAPI.Shipped.txt index 2e7b86ff..7977ca90 100644 --- a/src/Xunit.StaFact/net8.0/PublicAPI.Shipped.txt +++ b/src/Xunit.StaFact/net8.0/PublicAPI.Shipped.txt @@ -1,36 +1,43 @@ #nullable enable -override Xunit.Sdk.StaFactDiscoverer.CreateTestCase(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! factAttribute) -> Xunit.Sdk.IXunitTestCase! -override Xunit.Sdk.StaTheoryDiscoverer.CreateTestCasesForDataRow(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! theoryAttribute, object![]! dataRow) -> System.Collections.Generic.IEnumerable! -override Xunit.Sdk.StaTheoryDiscoverer.CreateTestCasesForTheory(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! theoryAttribute) -> System.Collections.Generic.IEnumerable! -override Xunit.Sdk.UIFactDiscoverer.CreateTestCase(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! factAttribute) -> Xunit.Sdk.IXunitTestCase! -override Xunit.Sdk.UITestCase.Deserialize(Xunit.Abstractions.IXunitSerializationInfo! data) -> void -override Xunit.Sdk.UITestCase.RunAsync(Xunit.Abstractions.IMessageSink! diagnosticMessageSink, Xunit.Sdk.IMessageBus! messageBus, object![]! constructorArguments, Xunit.Sdk.ExceptionAggregator! aggregator, System.Threading.CancellationTokenSource! cancellationTokenSource) -> System.Threading.Tasks.Task! -override Xunit.Sdk.UITestCase.Serialize(Xunit.Abstractions.IXunitSerializationInfo! data) -> void -override Xunit.Sdk.UITheoryDiscoverer.CreateTestCasesForDataRow(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! theoryAttribute, object![]! dataRow) -> System.Collections.Generic.IEnumerable! -override Xunit.Sdk.UITheoryDiscoverer.CreateTestCasesForTheory(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! theoryAttribute) -> System.Collections.Generic.IEnumerable! -override Xunit.Sdk.UITheoryTestCase.Deserialize(Xunit.Abstractions.IXunitSerializationInfo! data) -> void -override Xunit.Sdk.UITheoryTestCase.RunAsync(Xunit.Abstractions.IMessageSink! diagnosticMessageSink, Xunit.Sdk.IMessageBus! messageBus, object![]! constructorArguments, Xunit.Sdk.ExceptionAggregator! aggregator, System.Threading.CancellationTokenSource! cancellationTokenSource) -> System.Threading.Tasks.Task! -override Xunit.Sdk.UITheoryTestCase.Serialize(Xunit.Abstractions.IXunitSerializationInfo! data) -> void +override Xunit.Sdk.StaFactDiscoverer.CreateTestCase(Xunit.Sdk.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.v3.IXunitTestMethod! testMethod, Xunit.v3.IFactAttribute! factAttribute) -> Xunit.v3.IXunitTestCase! +override Xunit.Sdk.StaTheoryDiscoverer.CreateTestCasesForDataRow(Xunit.Sdk.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.v3.IXunitTestMethod! testMethod, Xunit.v3.ITheoryAttribute! theoryAttribute, Xunit.ITheoryDataRow! dataRow, object?[]! testMethodArguments) -> System.Threading.Tasks.ValueTask!> +override Xunit.Sdk.StaTheoryDiscoverer.CreateTestCasesForTheory(Xunit.Sdk.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.v3.IXunitTestMethod! testMethod, Xunit.v3.ITheoryAttribute! theoryAttribute) -> System.Threading.Tasks.ValueTask!> +override Xunit.Sdk.UIDelayEnumeratedTestCase.Deserialize(Xunit.Sdk.IXunitSerializationInfo! data) -> void +override Xunit.Sdk.UIDelayEnumeratedTestCase.Serialize(Xunit.Sdk.IXunitSerializationInfo! data) -> void +override Xunit.Sdk.UIFactDiscoverer.CreateTestCase(Xunit.Sdk.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.v3.IXunitTestMethod! testMethod, Xunit.v3.IFactAttribute! factAttribute) -> Xunit.v3.IXunitTestCase! +override Xunit.Sdk.UITestCase.Deserialize(Xunit.Sdk.IXunitSerializationInfo! data) -> void +override Xunit.Sdk.UITestCase.Serialize(Xunit.Sdk.IXunitSerializationInfo! data) -> void +override Xunit.Sdk.UITestRunner.RunTest(Xunit.Sdk.UITestRunnerContext! ctxt) -> System.Threading.Tasks.ValueTask +override Xunit.Sdk.UITheoryDiscoverer.CreateTestCasesForDataRow(Xunit.Sdk.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.v3.IXunitTestMethod! testMethod, Xunit.v3.ITheoryAttribute! theoryAttribute, Xunit.ITheoryDataRow! dataRow, object?[]! testMethodArguments) -> System.Threading.Tasks.ValueTask!> +override Xunit.Sdk.UITheoryDiscoverer.CreateTestCasesForTheory(Xunit.Sdk.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.v3.IXunitTestMethod! testMethod, Xunit.v3.ITheoryAttribute! theoryAttribute) -> System.Threading.Tasks.ValueTask!> +static Xunit.Sdk.UITestRunner.Instance.get -> Xunit.Sdk.UITestRunner! +Xunit.Sdk.SkippedTestCase +Xunit.Sdk.SkippedTestCase.SkippedTestCase() -> void Xunit.Sdk.StaFactDiscoverer -Xunit.Sdk.StaFactDiscoverer.StaFactDiscoverer(Xunit.Abstractions.IMessageSink! diagnosticMessageSink) -> void +Xunit.Sdk.StaFactDiscoverer.StaFactDiscoverer() -> void Xunit.Sdk.StaTheoryDiscoverer -Xunit.Sdk.StaTheoryDiscoverer.StaTheoryDiscoverer(Xunit.Abstractions.IMessageSink! diagnosticMessageSink) -> void +Xunit.Sdk.StaTheoryDiscoverer.StaTheoryDiscoverer() -> void +Xunit.Sdk.UIDelayEnumeratedTestCase +Xunit.Sdk.UIDelayEnumeratedTestCase.Run(Xunit.Sdk.ExplicitOption explicitOption, Xunit.v3.IMessageBus! messageBus, object?[]! constructorArguments, Xunit.v3.ExceptionAggregator aggregator, System.Threading.CancellationTokenSource! cancellationTokenSource) -> System.Threading.Tasks.ValueTask +Xunit.Sdk.UIDelayEnumeratedTestCase.UIDelayEnumeratedTestCase() -> void Xunit.Sdk.UIFactDiscoverer -Xunit.Sdk.UIFactDiscoverer.UIFactDiscoverer(Xunit.Abstractions.IMessageSink! diagnosticMessageSink) -> void +Xunit.Sdk.UIFactDiscoverer.UIFactDiscoverer() -> void Xunit.Sdk.UITestCase +Xunit.Sdk.UITestCase.Run(Xunit.Sdk.ExplicitOption explicitOption, Xunit.v3.IMessageBus! messageBus, object?[]! constructorArguments, Xunit.v3.ExceptionAggregator aggregator, System.Threading.CancellationTokenSource! cancellationTokenSource) -> System.Threading.Tasks.ValueTask Xunit.Sdk.UITestCase.SyncContextType Xunit.Sdk.UITestCase.SyncContextType.None = 0 -> Xunit.Sdk.UITestCase.SyncContextType Xunit.Sdk.UITestCase.SyncContextType.Portable = 1 -> Xunit.Sdk.UITestCase.SyncContextType Xunit.Sdk.UITestCase.UITestCase() -> void Xunit.Sdk.UITestCaseRunner -Xunit.Sdk.UITestInvoker -Xunit.Sdk.UITestInvoker.RunAsync() -> System.Threading.Tasks.Task! +Xunit.Sdk.UITestCaseRunner.Run(Xunit.v3.IXunitTestCase! testCase, Xunit.v3.IMessageBus! messageBus, Xunit.v3.ExceptionAggregator aggregator, System.Threading.CancellationTokenSource! cancellationTokenSource, string! displayName, string? skipReason, Xunit.Sdk.ExplicitOption explicitOption, object?[]! constructorArguments) -> System.Threading.Tasks.ValueTask +Xunit.Sdk.UITestCaseRunnerContext +Xunit.Sdk.UITestCaseRunnerContext.Settings.get -> Xunit.UISettingsAttribute! Xunit.Sdk.UITestRunner +Xunit.Sdk.UITestRunner.UITestRunner() -> void +Xunit.Sdk.UITestRunnerContext +Xunit.Sdk.UITestRunnerContext.Settings.get -> Xunit.UISettingsAttribute! Xunit.Sdk.UITheoryDiscoverer -Xunit.Sdk.UITheoryDiscoverer.UITheoryDiscoverer(Xunit.Abstractions.IMessageSink! diagnosticMessageSink) -> void -Xunit.Sdk.UITheoryTestCase -Xunit.Sdk.UITheoryTestCase.UITheoryTestCase() -> void -Xunit.Sdk.UITheoryTestCaseRunner +Xunit.Sdk.UITheoryDiscoverer.UITheoryDiscoverer() -> void Xunit.StaFactAttribute Xunit.StaFactAttribute.StaFactAttribute() -> void Xunit.StaTheoryAttribute diff --git a/src/Xunit.StaFact/netstandard2.0/PublicAPI.Shipped.txt b/src/Xunit.StaFact/netstandard2.0/PublicAPI.Shipped.txt index 2e7b86ff..7dc5c581 100644 --- a/src/Xunit.StaFact/netstandard2.0/PublicAPI.Shipped.txt +++ b/src/Xunit.StaFact/netstandard2.0/PublicAPI.Shipped.txt @@ -1,41 +1 @@ #nullable enable -override Xunit.Sdk.StaFactDiscoverer.CreateTestCase(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! factAttribute) -> Xunit.Sdk.IXunitTestCase! -override Xunit.Sdk.StaTheoryDiscoverer.CreateTestCasesForDataRow(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! theoryAttribute, object![]! dataRow) -> System.Collections.Generic.IEnumerable! -override Xunit.Sdk.StaTheoryDiscoverer.CreateTestCasesForTheory(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! theoryAttribute) -> System.Collections.Generic.IEnumerable! -override Xunit.Sdk.UIFactDiscoverer.CreateTestCase(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! factAttribute) -> Xunit.Sdk.IXunitTestCase! -override Xunit.Sdk.UITestCase.Deserialize(Xunit.Abstractions.IXunitSerializationInfo! data) -> void -override Xunit.Sdk.UITestCase.RunAsync(Xunit.Abstractions.IMessageSink! diagnosticMessageSink, Xunit.Sdk.IMessageBus! messageBus, object![]! constructorArguments, Xunit.Sdk.ExceptionAggregator! aggregator, System.Threading.CancellationTokenSource! cancellationTokenSource) -> System.Threading.Tasks.Task! -override Xunit.Sdk.UITestCase.Serialize(Xunit.Abstractions.IXunitSerializationInfo! data) -> void -override Xunit.Sdk.UITheoryDiscoverer.CreateTestCasesForDataRow(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! theoryAttribute, object![]! dataRow) -> System.Collections.Generic.IEnumerable! -override Xunit.Sdk.UITheoryDiscoverer.CreateTestCasesForTheory(Xunit.Abstractions.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.Abstractions.ITestMethod! testMethod, Xunit.Abstractions.IAttributeInfo! theoryAttribute) -> System.Collections.Generic.IEnumerable! -override Xunit.Sdk.UITheoryTestCase.Deserialize(Xunit.Abstractions.IXunitSerializationInfo! data) -> void -override Xunit.Sdk.UITheoryTestCase.RunAsync(Xunit.Abstractions.IMessageSink! diagnosticMessageSink, Xunit.Sdk.IMessageBus! messageBus, object![]! constructorArguments, Xunit.Sdk.ExceptionAggregator! aggregator, System.Threading.CancellationTokenSource! cancellationTokenSource) -> System.Threading.Tasks.Task! -override Xunit.Sdk.UITheoryTestCase.Serialize(Xunit.Abstractions.IXunitSerializationInfo! data) -> void -Xunit.Sdk.StaFactDiscoverer -Xunit.Sdk.StaFactDiscoverer.StaFactDiscoverer(Xunit.Abstractions.IMessageSink! diagnosticMessageSink) -> void -Xunit.Sdk.StaTheoryDiscoverer -Xunit.Sdk.StaTheoryDiscoverer.StaTheoryDiscoverer(Xunit.Abstractions.IMessageSink! diagnosticMessageSink) -> void -Xunit.Sdk.UIFactDiscoverer -Xunit.Sdk.UIFactDiscoverer.UIFactDiscoverer(Xunit.Abstractions.IMessageSink! diagnosticMessageSink) -> void -Xunit.Sdk.UITestCase -Xunit.Sdk.UITestCase.SyncContextType -Xunit.Sdk.UITestCase.SyncContextType.None = 0 -> Xunit.Sdk.UITestCase.SyncContextType -Xunit.Sdk.UITestCase.SyncContextType.Portable = 1 -> Xunit.Sdk.UITestCase.SyncContextType -Xunit.Sdk.UITestCase.UITestCase() -> void -Xunit.Sdk.UITestCaseRunner -Xunit.Sdk.UITestInvoker -Xunit.Sdk.UITestInvoker.RunAsync() -> System.Threading.Tasks.Task! -Xunit.Sdk.UITestRunner -Xunit.Sdk.UITheoryDiscoverer -Xunit.Sdk.UITheoryDiscoverer.UITheoryDiscoverer(Xunit.Abstractions.IMessageSink! diagnosticMessageSink) -> void -Xunit.Sdk.UITheoryTestCase -Xunit.Sdk.UITheoryTestCase.UITheoryTestCase() -> void -Xunit.Sdk.UITheoryTestCaseRunner -Xunit.StaFactAttribute -Xunit.StaFactAttribute.StaFactAttribute() -> void -Xunit.StaTheoryAttribute -Xunit.StaTheoryAttribute.StaTheoryAttribute() -> void -Xunit.UIFactAttribute -Xunit.UIFactAttribute.UIFactAttribute() -> void -Xunit.UITheoryAttribute -Xunit.UITheoryAttribute.UITheoryAttribute() -> void diff --git a/src/Xunit.StaFact/netstandard2.0/PublicAPI.Unshipped.txt b/src/Xunit.StaFact/netstandard2.0/PublicAPI.Unshipped.txt index 332ae6fc..9a28bfe1 100644 --- a/src/Xunit.StaFact/netstandard2.0/PublicAPI.Unshipped.txt +++ b/src/Xunit.StaFact/netstandard2.0/PublicAPI.Unshipped.txt @@ -1,4 +1,51 @@ +override Xunit.Sdk.StaFactDiscoverer.CreateTestCase(Xunit.Sdk.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.v3.IXunitTestMethod! testMethod, Xunit.v3.IFactAttribute! factAttribute) -> Xunit.v3.IXunitTestCase! +override Xunit.Sdk.StaTheoryDiscoverer.CreateTestCasesForDataRow(Xunit.Sdk.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.v3.IXunitTestMethod! testMethod, Xunit.v3.ITheoryAttribute! theoryAttribute, Xunit.ITheoryDataRow! dataRow, object?[]! testMethodArguments) -> System.Threading.Tasks.ValueTask!> +override Xunit.Sdk.StaTheoryDiscoverer.CreateTestCasesForTheory(Xunit.Sdk.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.v3.IXunitTestMethod! testMethod, Xunit.v3.ITheoryAttribute! theoryAttribute) -> System.Threading.Tasks.ValueTask!> +override Xunit.Sdk.UIDelayEnumeratedTestCase.Deserialize(Xunit.Sdk.IXunitSerializationInfo! data) -> void +override Xunit.Sdk.UIDelayEnumeratedTestCase.Serialize(Xunit.Sdk.IXunitSerializationInfo! data) -> void +override Xunit.Sdk.UIFactDiscoverer.CreateTestCase(Xunit.Sdk.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.v3.IXunitTestMethod! testMethod, Xunit.v3.IFactAttribute! factAttribute) -> Xunit.v3.IXunitTestCase! +override Xunit.Sdk.UITestCase.Deserialize(Xunit.Sdk.IXunitSerializationInfo! data) -> void +override Xunit.Sdk.UITestCase.Serialize(Xunit.Sdk.IXunitSerializationInfo! data) -> void +override Xunit.Sdk.UITestRunner.RunTest(Xunit.Sdk.UITestRunnerContext! ctxt) -> System.Threading.Tasks.ValueTask +override Xunit.Sdk.UITheoryDiscoverer.CreateTestCasesForDataRow(Xunit.Sdk.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.v3.IXunitTestMethod! testMethod, Xunit.v3.ITheoryAttribute! theoryAttribute, Xunit.ITheoryDataRow! dataRow, object?[]! testMethodArguments) -> System.Threading.Tasks.ValueTask!> +override Xunit.Sdk.UITheoryDiscoverer.CreateTestCasesForTheory(Xunit.Sdk.ITestFrameworkDiscoveryOptions! discoveryOptions, Xunit.v3.IXunitTestMethod! testMethod, Xunit.v3.ITheoryAttribute! theoryAttribute) -> System.Threading.Tasks.ValueTask!> +static Xunit.Sdk.UITestRunner.Instance.get -> Xunit.Sdk.UITestRunner! +Xunit.Sdk.SkippedTestCase +Xunit.Sdk.SkippedTestCase.SkippedTestCase() -> void +Xunit.Sdk.StaFactDiscoverer +Xunit.Sdk.StaFactDiscoverer.StaFactDiscoverer() -> void +Xunit.Sdk.StaTheoryDiscoverer +Xunit.Sdk.StaTheoryDiscoverer.StaTheoryDiscoverer() -> void +Xunit.Sdk.UIDelayEnumeratedTestCase +Xunit.Sdk.UIDelayEnumeratedTestCase.Run(Xunit.Sdk.ExplicitOption explicitOption, Xunit.v3.IMessageBus! messageBus, object?[]! constructorArguments, Xunit.v3.ExceptionAggregator aggregator, System.Threading.CancellationTokenSource! cancellationTokenSource) -> System.Threading.Tasks.ValueTask +Xunit.Sdk.UIDelayEnumeratedTestCase.UIDelayEnumeratedTestCase() -> void +Xunit.Sdk.UIFactDiscoverer +Xunit.Sdk.UIFactDiscoverer.UIFactDiscoverer() -> void +Xunit.Sdk.UITestCase +Xunit.Sdk.UITestCase.Run(Xunit.Sdk.ExplicitOption explicitOption, Xunit.v3.IMessageBus! messageBus, object?[]! constructorArguments, Xunit.v3.ExceptionAggregator aggregator, System.Threading.CancellationTokenSource! cancellationTokenSource) -> System.Threading.Tasks.ValueTask +Xunit.Sdk.UITestCase.SyncContextType +Xunit.Sdk.UITestCase.SyncContextType.None = 0 -> Xunit.Sdk.UITestCase.SyncContextType +Xunit.Sdk.UITestCase.SyncContextType.Portable = 1 -> Xunit.Sdk.UITestCase.SyncContextType +Xunit.Sdk.UITestCase.UITestCase() -> void +Xunit.Sdk.UITestCaseRunner +Xunit.Sdk.UITestCaseRunner.Run(Xunit.v3.IXunitTestCase! testCase, Xunit.v3.IMessageBus! messageBus, Xunit.v3.ExceptionAggregator aggregator, System.Threading.CancellationTokenSource! cancellationTokenSource, string! displayName, string? skipReason, Xunit.Sdk.ExplicitOption explicitOption, object?[]! constructorArguments) -> System.Threading.Tasks.ValueTask +Xunit.Sdk.UITestCaseRunnerContext +Xunit.Sdk.UITestCaseRunnerContext.Settings.get -> Xunit.UISettingsAttribute! +Xunit.Sdk.UITestRunner +Xunit.Sdk.UITestRunner.UITestRunner() -> void +Xunit.Sdk.UITestRunnerContext +Xunit.Sdk.UITestRunnerContext.Settings.get -> Xunit.UISettingsAttribute! +Xunit.Sdk.UITheoryDiscoverer +Xunit.Sdk.UITheoryDiscoverer.UITheoryDiscoverer() -> void +Xunit.StaFactAttribute +Xunit.StaFactAttribute.StaFactAttribute() -> void +Xunit.StaTheoryAttribute +Xunit.StaTheoryAttribute.StaTheoryAttribute() -> void +Xunit.UIFactAttribute +Xunit.UIFactAttribute.UIFactAttribute() -> void Xunit.UISettingsAttribute Xunit.UISettingsAttribute.MaxAttempts.get -> int Xunit.UISettingsAttribute.MaxAttempts.set -> void Xunit.UISettingsAttribute.UISettingsAttribute() -> void +Xunit.UITheoryAttribute +Xunit.UITheoryAttribute.UITheoryAttribute() -> void \ No newline at end of file From d89f0bec20b0e11bdef9baa79cbaee867244e7b4 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 15 Jan 2025 19:28:48 -0700 Subject: [PATCH 14/27] Drop support for `async void` tests This was causing tests to hang, and xunit v3 doesn't support it any more anyway. --- .../CocoaSynchronizationContextAdapter.cs | 4 --- ...DispatcherSynchronizationContextAdapter.cs | 7 ---- .../WinFormsSynchronizationContextAdapter.cs | 7 ---- src/Xunit.StaFact/Sdk/SyncContextAdapter.cs | 12 ------- .../Sdk/UISynchronizationContext.cs | 32 ------------------- src/Xunit.StaFact/Sdk/UITestRunner.cs | 9 ------ 6 files changed, 71 deletions(-) diff --git a/src/Xunit.StaFact/Sdk.Mac/CocoaSynchronizationContextAdapter.cs b/src/Xunit.StaFact/Sdk.Mac/CocoaSynchronizationContextAdapter.cs index b474c46f..cfc21eda 100644 --- a/src/Xunit.StaFact/Sdk.Mac/CocoaSynchronizationContextAdapter.cs +++ b/src/Xunit.StaFact/Sdk.Mac/CocoaSynchronizationContextAdapter.cs @@ -11,12 +11,8 @@ private CocoaSynchronizationContextAdapter() { } - internal override bool CanCompleteOperations => true; - internal override SynchronizationContext Create(string name) => new CocoaSynchronizationContext(name, this.ShouldSetAsCurrent); - internal override Task WaitForOperationCompletionAsync(SynchronizationContext syncContext) => ((CocoaSynchronizationContext)syncContext).WaitForOperationCompletionAsync(); - internal override void PumpTill(SynchronizationContext synchronizationContext, Task task) { ((CocoaSynchronizationContext)synchronizationContext).PumpMessages(task); diff --git a/src/Xunit.StaFact/Sdk.WindowsDesktop/DispatcherSynchronizationContextAdapter.cs b/src/Xunit.StaFact/Sdk.WindowsDesktop/DispatcherSynchronizationContextAdapter.cs index 9ed0647a..7c98873a 100644 --- a/src/Xunit.StaFact/Sdk.WindowsDesktop/DispatcherSynchronizationContextAdapter.cs +++ b/src/Xunit.StaFact/Sdk.WindowsDesktop/DispatcherSynchronizationContextAdapter.cs @@ -13,15 +13,8 @@ private DispatcherSynchronizationContextAdapter() { } - internal override bool CanCompleteOperations => false; - internal override SynchronizationContext Create(string name) => new DispatcherSynchronizationContext(); - internal override Task WaitForOperationCompletionAsync(SynchronizationContext syncContext) - { - throw new NotSupportedException("Async void test methods are not supported by the WPF dispatcher. Use Async Task instead."); - } - internal override void PumpTill(SynchronizationContext synchronizationContext, Task task) { if (!task.IsCompleted) diff --git a/src/Xunit.StaFact/Sdk.WindowsDesktop/WinFormsSynchronizationContextAdapter.cs b/src/Xunit.StaFact/Sdk.WindowsDesktop/WinFormsSynchronizationContextAdapter.cs index 27969d51..92615cd8 100644 --- a/src/Xunit.StaFact/Sdk.WindowsDesktop/WinFormsSynchronizationContextAdapter.cs +++ b/src/Xunit.StaFact/Sdk.WindowsDesktop/WinFormsSynchronizationContextAdapter.cs @@ -20,15 +20,8 @@ private WinFormsSynchronizationContextAdapter() { } - internal override bool CanCompleteOperations => false; - internal override SynchronizationContext Create(string name) => new WindowsFormsSynchronizationContext(); - internal override Task WaitForOperationCompletionAsync(SynchronizationContext syncContext) - { - throw new NotSupportedException("Async void test methods are not supported by the WinForms dispatcher. Use Async Task instead."); - } - internal override void PumpTill(SynchronizationContext synchronizationContext, Task task) { while (!task.IsCompleted) diff --git a/src/Xunit.StaFact/Sdk/SyncContextAdapter.cs b/src/Xunit.StaFact/Sdk/SyncContextAdapter.cs index 89cc83b8..be46d140 100644 --- a/src/Xunit.StaFact/Sdk/SyncContextAdapter.cs +++ b/src/Xunit.StaFact/Sdk/SyncContextAdapter.cs @@ -9,12 +9,6 @@ namespace Xunit.Sdk; /// internal abstract class SyncContextAdapter { - /// - /// Gets a value indicating whether async void methods are supported. - /// - /// if can be invoked. - internal virtual bool CanCompleteOperations => true; - internal virtual bool ShouldSetAsCurrent => true; /// @@ -38,12 +32,6 @@ internal virtual void InitializeThread() /// The task to wait on. internal abstract void PumpTill(SynchronizationContext syncContext, Task task); - /// - /// Returns a that completes when all pending operations have completed. - /// - /// A that completes when all pending operations have completed. - internal abstract Task WaitForOperationCompletionAsync(SynchronizationContext syncContext); - /// /// Clean up this instance. /// diff --git a/src/Xunit.StaFact/Sdk/UISynchronizationContext.cs b/src/Xunit.StaFact/Sdk/UISynchronizationContext.cs index 3f3f1e73..c83ef487 100644 --- a/src/Xunit.StaFact/Sdk/UISynchronizationContext.cs +++ b/src/Xunit.StaFact/Sdk/UISynchronizationContext.cs @@ -79,36 +79,6 @@ public void PumpMessages(Task untilCompleted) } } - public async Task WaitForOperationCompletionAsync() - { - while (this.AnyPendingOperations || this.AnyMessagesInQueue) - { - await this.workItemDone.WaitAsync().ConfigureAwait(false); - } - } - - /// - public override void OperationStarted() - { - Interlocked.Increment(ref this.activeOperations); - } - - /// - public override void OperationCompleted() - { - int result = Interlocked.Decrement(ref this.activeOperations); - if (result == 0) - { - // Give any message waiter a heads up that the operation count has reached zero, - // in case the queue is empty at the same time the operation count is, which - // is usually a sign to return to its caller. - lock (this.messageQueue) - { - Monitor.Pulse(this.messageQueue); - } - } - } - /// public override void Post(SendOrPostCallback d, object? state) { @@ -226,8 +196,6 @@ protected Adapter() internal override SynchronizationContext Create(string name) => new UISynchronizationContext(name, this.ShouldSetAsCurrent); - internal override Task WaitForOperationCompletionAsync(SynchronizationContext syncContext) => ((UISynchronizationContext)syncContext).WaitForOperationCompletionAsync(); - internal override void PumpTill(SynchronizationContext syncContext, Task task) { ((UISynchronizationContext)syncContext).PumpMessages(task); diff --git a/src/Xunit.StaFact/Sdk/UITestRunner.cs b/src/Xunit.StaFact/Sdk/UITestRunner.cs index 5afc2a74..0ab23a52 100644 --- a/src/Xunit.StaFact/Sdk/UITestRunner.cs +++ b/src/Xunit.StaFact/Sdk/UITestRunner.cs @@ -97,15 +97,6 @@ async void RunTest(object? state) { await ctxt.ThreadRental.SynchronizationContext; TimeSpan invokeTime = await this.InvokeTest(ctxt, testClassInstance); - - if (ctxt.ThreadRental.SyncContextAdapter.CanCompleteOperations) - { - invokeTime += await ExecutionTimer.MeasureAsync(async () => - { - await ctxt.ThreadRental.SyncContextAdapter.WaitForOperationCompletionAsync(ctxt.ThreadRental.SynchronizationContext).ConfigureAwait(false); - }); - } - return invokeTime; }, TimeSpan.Zero); From 1bbadb9a53d987457e07e3991c864916fb1fe7d3 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 15 Jan 2025 19:36:44 -0700 Subject: [PATCH 15/27] Avoid `async void` tests within our own tests --- test/Xunit.StaFact.Tests/UIFactTests.cs | 8 ++++---- test/Xunit.StaFact.Tests/UITheoryTests.cs | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/test/Xunit.StaFact.Tests/UIFactTests.cs b/test/Xunit.StaFact.Tests/UIFactTests.cs index 9dcea6fb..89fdaa9a 100644 --- a/test/Xunit.StaFact.Tests/UIFactTests.cs +++ b/test/Xunit.StaFact.Tests/UIFactTests.cs @@ -56,28 +56,28 @@ public async Task CtorAndTestMethodInvokedInSameContext_AcrossYields() } [UIFact] - public async void PassAfterYield() + public async Task PassAfterYield() { // This will post to the SynchronizationContext before yielding. await Task.Yield(); } [UIFact] - public async void PassAfterDelay() + public async Task PassAfterDelay() { // This won't post to the SynchronizationContext till after the delay. await Task.Delay(10); } [UIFact, Trait("TestCategory", "FailureExpected")] - public async void FailAfterYield() + public async Task FailAfterYield() { await Task.Yield(); Assert.False(true); } [UIFact, Trait("TestCategory", "FailureExpected")] - public async void FailAfterDelay() + public async Task FailAfterDelay() { await Task.Delay(10); Assert.False(true); diff --git a/test/Xunit.StaFact.Tests/UITheoryTests.cs b/test/Xunit.StaFact.Tests/UITheoryTests.cs index 2204f721..e8f69883 100644 --- a/test/Xunit.StaFact.Tests/UITheoryTests.cs +++ b/test/Xunit.StaFact.Tests/UITheoryTests.cs @@ -61,7 +61,7 @@ public async Task CtorAndTestMethodInvokedInSameContext_AcrossYields(int arg) [UITheory] [InlineData(0)] - public async void PassAfterYield(int arg) + public async Task PassAfterYield(int arg) { // This will post to the SynchronizationContext before yielding. await Task.Yield(); @@ -70,7 +70,7 @@ public async void PassAfterYield(int arg) [UITheory] [InlineData(0)] - public async void PassAfterDelay(int arg) + public async Task PassAfterDelay(int arg) { // This won't post to the SynchronizationContext till after the delay. await Task.Delay(10); @@ -79,7 +79,7 @@ public async void PassAfterDelay(int arg) [UITheory, Trait("TestCategory", "FailureExpected")] [InlineData(0)] - public async void FailAfterYield(int arg) + public async Task FailAfterYield(int arg) { await Task.Yield(); Assert.Equal(1, arg); @@ -87,7 +87,7 @@ public async void FailAfterYield(int arg) [UITheory, Trait("TestCategory", "FailureExpected")] [InlineData(0)] - public async void FailAfterDelay(int arg) + public async Task FailAfterDelay(int arg) { await Task.Delay(10); Assert.Equal(1, arg); From 0495b9419288910a824be2258e2ec65287989852 Mon Sep 17 00:00:00 2001 From: reduckted Date: Thu, 16 Jan 2025 22:17:36 +1000 Subject: [PATCH 16/27] Pass test method arguments when creating UITestCase. --- src/Xunit.StaFact/Sdk/Utilities.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Xunit.StaFact/Sdk/Utilities.cs b/src/Xunit.StaFact/Sdk/Utilities.cs index 0c9872d4..2cbfbc07 100644 --- a/src/Xunit.StaFact/Sdk/Utilities.cs +++ b/src/Xunit.StaFact/Sdk/Utilities.cs @@ -72,7 +72,7 @@ internal static IXunitTestCase CreateTestCase( details.SkipUnless, details.SkipWhen, traits, - null, + testMethodArguments, timeout: details.Timeout); } From 9c2148e88b763562a3a2cccbd3273086e8269eed Mon Sep 17 00:00:00 2001 From: reduckted Date: Fri, 17 Jan 2025 21:39:35 +1000 Subject: [PATCH 17/27] Set synchronization context when running test. --- src/Xunit.StaFact/Sdk/UITestRunner.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Xunit.StaFact/Sdk/UITestRunner.cs b/src/Xunit.StaFact/Sdk/UITestRunner.cs index 0ab23a52..cb69fc23 100644 --- a/src/Xunit.StaFact/Sdk/UITestRunner.cs +++ b/src/Xunit.StaFact/Sdk/UITestRunner.cs @@ -75,9 +75,7 @@ protected async override ValueTask RunTest(UITestRunnerContext ctxt) async void RunTest(object? state) { - // At this point, xUnit would set the synchronization context to - // the one that was used when creating the test class. We have - // our synchronization context that we use, so we don't do that. + SynchronizationContext.SetSynchronizationContext(syncContext); this.UpdateTestContext(testClassInstance); try From 5c3a2d5cd3d38a6afa429649ddfd66b5c6c6c410 Mon Sep 17 00:00:00 2001 From: reduckted Date: Fri, 17 Jan 2025 21:40:28 +1000 Subject: [PATCH 18/27] Removed unused properties. --- src/Xunit.StaFact/Sdk/UISynchronizationContext.cs | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/Xunit.StaFact/Sdk/UISynchronizationContext.cs b/src/Xunit.StaFact/Sdk/UISynchronizationContext.cs index c83ef487..77974861 100644 --- a/src/Xunit.StaFact/Sdk/UISynchronizationContext.cs +++ b/src/Xunit.StaFact/Sdk/UISynchronizationContext.cs @@ -31,19 +31,6 @@ public UISynchronizationContext(string name, bool shouldSetAsCurrent) internal bool IsInContext => this.mainThread == Environment.CurrentManagedThreadId; - private bool AnyMessagesInQueue - { - get - { - lock (this.messageQueue) - { - return this.messageQueue.Count > 0; - } - } - } - - private bool AnyPendingOperations => Volatile.Read(ref this.activeOperations) > 0; - /// /// Blocks the calling thread to pump messages until a task has completed. /// From be1e48adba4a3473c754cba543e429811e2c0bc8 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 17 Jan 2025 06:46:32 -0700 Subject: [PATCH 19/27] Add disposal SyncContext test for StaFact --- test/Xunit.StaFact.Tests/StaFactCtorSyncContextTests.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/Xunit.StaFact.Tests/StaFactCtorSyncContextTests.cs b/test/Xunit.StaFact.Tests/StaFactCtorSyncContextTests.cs index e170c6be..ee1489cd 100644 --- a/test/Xunit.StaFact.Tests/StaFactCtorSyncContextTests.cs +++ b/test/Xunit.StaFact.Tests/StaFactCtorSyncContextTests.cs @@ -1,7 +1,7 @@ // Copyright (c) Andrew Arnott. All rights reserved. // Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. -public class StaFactCtorSyncContextTests +public class StaFactCtorSyncContextTests : IDisposable { private readonly SynchronizationContext ctorSyncContext; @@ -17,4 +17,9 @@ public void SyncContextPreservedFromCtor() { Assert.Same(this.ctorSyncContext, SynchronizationContext.Current); } + + public void Dispose() + { + Assert.Same(this.ctorSyncContext, SynchronizationContext.Current); + } } From b5225345ef5392c61dcffbac15ddb060d5ba8767 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 17 Jan 2025 06:56:08 -0700 Subject: [PATCH 20/27] Document versions to use for xUnit v2 and v3 support --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 1196be1d..f6422472 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,15 @@ Simply use `[WpfFact]`, `[WinFormsFact]`, `[StaFact]` or the cross-platform `[UI Theory variants of these attributes allow for parameterized testing. Check out the xunit.combinatorial nuget package for pairwise or combinatorial testing with theories. +## xUnit v2 vs. v3 + +With xUnit v3 now available with breaking changes from v2, see the following table for how we support both versions: + +xUnit | Xunit.STAFact +--|-- +For xUnit v2 support | Use Xunit.STAFact 1.x +For xUnit v3 support | Use Xunit.STAFact 2.x+ + ## Features The following test attributes are supported: From ea0a5cb316907288b3ac72dee319485593239eaa Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 17 Jan 2025 06:59:49 -0700 Subject: [PATCH 21/27] Update CONTRIBUTING.md --- CONTRIBUTING.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7554b520..f41bd4fb 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -12,6 +12,10 @@ with any additional questions or comments. * Use Windows PowerShell or [PowerShell Core][pwsh] (including on Linux/OSX) to run .ps1 scripts. Some scripts set environment variables to help you, but they are only retained if you use PowerShell as your shell. +## Branches + +xUnit v2 support is maintained in the `v1.x` branch, while xUnit v3 is maintained in the `main` branch. + ## Prerequisites The only prerequisite for building, testing, and deploying from this repository @@ -20,7 +24,7 @@ You should install the version specified in `global.json` or a later version wit the same major.minor.Bxx "hundreds" band. For example if 2.2.300 is specified, you may install 2.2.300, 2.2.301, or 2.2.310 while the 2.2.400 version would not be considered compatible by .NET SDK. -See [.NET Core Versioning](https://docs.microsoft.com/en-us/dotnet/core/versions/) for more information. +See [.NET Core Versioning](https://docs.microsoft.com/dotnet/core/versions/) for more information. All dependencies can be installed by running the `init.ps1` script at the root of the repository using Windows PowerShell or [PowerShell Core][pwsh] (on any OS). From 9192cbf4a5299f02ee6fd5e80587a645689bede4 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 17 Jan 2025 07:07:11 -0700 Subject: [PATCH 22/27] Fix compile warning --- src/Xunit.StaFact/Sdk/UISynchronizationContext.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Xunit.StaFact/Sdk/UISynchronizationContext.cs b/src/Xunit.StaFact/Sdk/UISynchronizationContext.cs index 77974861..99ee9692 100644 --- a/src/Xunit.StaFact/Sdk/UISynchronizationContext.cs +++ b/src/Xunit.StaFact/Sdk/UISynchronizationContext.cs @@ -15,7 +15,6 @@ internal class UISynchronizationContext : SynchronizationContext private readonly AsyncAutoResetEvent workItemDone = new AsyncAutoResetEvent(); private readonly string name; private readonly bool shouldSetAsCurrent; - private int activeOperations; private bool pumping; private bool pumpingEnded; private ExceptionAggregator? aggregator; From 3b4dc053820bc146f521fe075fa1901b045d0102 Mon Sep 17 00:00:00 2001 From: reduckted Date: Sat, 18 Jan 2025 13:07:47 +1000 Subject: [PATCH 23/27] Fixed test case serialization of `SyncContextType`. --- src/Xunit.StaFact/Sdk/UIDelayEnumeratedTestCase.cs | 8 ++------ src/Xunit.StaFact/Sdk/UITestCase.cs | 9 ++------- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/src/Xunit.StaFact/Sdk/UIDelayEnumeratedTestCase.cs b/src/Xunit.StaFact/Sdk/UIDelayEnumeratedTestCase.cs index 4cccfb01..74f54ea5 100644 --- a/src/Xunit.StaFact/Sdk/UIDelayEnumeratedTestCase.cs +++ b/src/Xunit.StaFact/Sdk/UIDelayEnumeratedTestCase.cs @@ -70,7 +70,7 @@ protected override void Serialize(IXunitSerializationInfo data) base.Serialize(data); data.AddValue(nameof(UISettingsAttribute.MaxAttempts), this.settings.MaxAttempts); - data.AddValue(nameof(this.synchronizationContextType), this.synchronizationContextType); + data.AddValue(nameof(this.synchronizationContextType), (int)this.synchronizationContextType); } protected override void Deserialize(IXunitSerializationInfo data) @@ -85,10 +85,6 @@ protected override void Deserialize(IXunitSerializationInfo data) { MaxAttempts = data.GetValue(nameof(UISettingsAttribute.MaxAttempts)), }; - string? syncContextTypeName = data.GetValue(nameof(this.synchronizationContextType)); - if (syncContextTypeName is not null) - { - this.synchronizationContextType = (UITestCase.SyncContextType)Enum.Parse(typeof(UITestCase.SyncContextType), syncContextTypeName); - } + this.synchronizationContextType = (UITestCase.SyncContextType)data.GetValue(nameof(this.synchronizationContextType)); } } diff --git a/src/Xunit.StaFact/Sdk/UITestCase.cs b/src/Xunit.StaFact/Sdk/UITestCase.cs index 9c1ea62d..e9e82790 100644 --- a/src/Xunit.StaFact/Sdk/UITestCase.cs +++ b/src/Xunit.StaFact/Sdk/UITestCase.cs @@ -3,7 +3,6 @@ using System.ComponentModel; using System.Diagnostics; -using static Xunit.Sdk.UISynchronizationContext; namespace Xunit.Sdk; @@ -157,7 +156,7 @@ protected override void Serialize(IXunitSerializationInfo data) base.Serialize(data); data.AddValue(nameof(UISettingsAttribute.MaxAttempts), this.settings.MaxAttempts); - data.AddValue(nameof(this.synchronizationContextType), this.synchronizationContextType); + data.AddValue(nameof(this.synchronizationContextType), (int)this.synchronizationContextType); } protected override void Deserialize(IXunitSerializationInfo data) @@ -172,11 +171,7 @@ protected override void Deserialize(IXunitSerializationInfo data) { MaxAttempts = data.GetValue(nameof(UISettingsAttribute.MaxAttempts)), }; - string? syncContextTypeName = data.GetValue(nameof(this.synchronizationContextType)); - if (syncContextTypeName is not null) - { - this.synchronizationContextType = (SyncContextType)Enum.Parse(typeof(SyncContextType), syncContextTypeName); - } + this.synchronizationContextType = (SyncContextType)data.GetValue(nameof(this.synchronizationContextType)); } private class NullAdapter : UISynchronizationContext.Adapter From 4de628ffb8c2b42b1684e464437c0585d0077f23 Mon Sep 17 00:00:00 2001 From: reduckted Date: Sat, 18 Jan 2025 13:24:34 +1000 Subject: [PATCH 24/27] Avoided casting enum to int. --- src/Xunit.StaFact/Sdk/UIDelayEnumeratedTestCase.cs | 4 ++-- src/Xunit.StaFact/Sdk/UITestCase.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Xunit.StaFact/Sdk/UIDelayEnumeratedTestCase.cs b/src/Xunit.StaFact/Sdk/UIDelayEnumeratedTestCase.cs index 74f54ea5..e4f046f3 100644 --- a/src/Xunit.StaFact/Sdk/UIDelayEnumeratedTestCase.cs +++ b/src/Xunit.StaFact/Sdk/UIDelayEnumeratedTestCase.cs @@ -70,7 +70,7 @@ protected override void Serialize(IXunitSerializationInfo data) base.Serialize(data); data.AddValue(nameof(UISettingsAttribute.MaxAttempts), this.settings.MaxAttempts); - data.AddValue(nameof(this.synchronizationContextType), (int)this.synchronizationContextType); + data.AddValue(nameof(this.synchronizationContextType), this.synchronizationContextType); } protected override void Deserialize(IXunitSerializationInfo data) @@ -85,6 +85,6 @@ protected override void Deserialize(IXunitSerializationInfo data) { MaxAttempts = data.GetValue(nameof(UISettingsAttribute.MaxAttempts)), }; - this.synchronizationContextType = (UITestCase.SyncContextType)data.GetValue(nameof(this.synchronizationContextType)); + this.synchronizationContextType = data.GetValue(nameof(this.synchronizationContextType)); } } diff --git a/src/Xunit.StaFact/Sdk/UITestCase.cs b/src/Xunit.StaFact/Sdk/UITestCase.cs index e9e82790..36de5ef8 100644 --- a/src/Xunit.StaFact/Sdk/UITestCase.cs +++ b/src/Xunit.StaFact/Sdk/UITestCase.cs @@ -156,7 +156,7 @@ protected override void Serialize(IXunitSerializationInfo data) base.Serialize(data); data.AddValue(nameof(UISettingsAttribute.MaxAttempts), this.settings.MaxAttempts); - data.AddValue(nameof(this.synchronizationContextType), (int)this.synchronizationContextType); + data.AddValue(nameof(this.synchronizationContextType), this.synchronizationContextType); } protected override void Deserialize(IXunitSerializationInfo data) @@ -171,7 +171,7 @@ protected override void Deserialize(IXunitSerializationInfo data) { MaxAttempts = data.GetValue(nameof(UISettingsAttribute.MaxAttempts)), }; - this.synchronizationContextType = (SyncContextType)data.GetValue(nameof(this.synchronizationContextType)); + this.synchronizationContextType = data.GetValue(nameof(this.synchronizationContextType)); } private class NullAdapter : UISynchronizationContext.Adapter From 24d2aa861bcb77efc3977c332a14646d7bf019e1 Mon Sep 17 00:00:00 2001 From: reduckted Date: Sat, 18 Jan 2025 13:58:41 +1000 Subject: [PATCH 25/27] Prevented data row test cases from being reported as duplicate tests. --- .../Sdk.Mac/CocoaFactDiscoverer.cs | 2 +- .../Sdk.Mac/CocoaTheoryDiscoverer.cs | 10 +- src/Xunit.StaFact/Sdk.Mac/CocoaUtilities.cs | 45 +++++-- .../WinFormsFactDiscoverer.cs | 6 +- .../WinFormsTheoryDiscoverer.cs | 10 +- .../Sdk.WindowsDesktop/WinFormsUtilities.cs | 45 +++++-- .../Sdk.WindowsDesktop/WpfFactDiscoverer.cs | 9 +- .../Sdk.WindowsDesktop/WpfTheoryDiscoverer.cs | 10 +- .../Sdk.WindowsDesktop/WpfUtilities.cs | 45 +++++-- src/Xunit.StaFact/Sdk/StaFactDiscoverer.cs | 2 +- src/Xunit.StaFact/Sdk/StaTheoryDiscoverer.cs | 10 +- src/Xunit.StaFact/Sdk/StaUtilities.cs | 45 +++++-- src/Xunit.StaFact/Sdk/TestCaseKind.cs | 11 -- src/Xunit.StaFact/Sdk/UIFactDiscoverer.cs | 2 +- src/Xunit.StaFact/Sdk/UITheoryDiscoverer.cs | 10 +- src/Xunit.StaFact/Sdk/UIUtilities.cs | 47 +++++-- src/Xunit.StaFact/Sdk/Utilities.cs | 121 +++++++++++++----- 17 files changed, 302 insertions(+), 128 deletions(-) delete mode 100644 src/Xunit.StaFact/Sdk/TestCaseKind.cs diff --git a/src/Xunit.StaFact/Sdk.Mac/CocoaFactDiscoverer.cs b/src/Xunit.StaFact/Sdk.Mac/CocoaFactDiscoverer.cs index 6f5f83ec..61dca5de 100644 --- a/src/Xunit.StaFact/Sdk.Mac/CocoaFactDiscoverer.cs +++ b/src/Xunit.StaFact/Sdk.Mac/CocoaFactDiscoverer.cs @@ -11,6 +11,6 @@ public class CocoaFactDiscoverer : FactDiscoverer /// protected override IXunitTestCase CreateTestCase(ITestFrameworkDiscoveryOptions discoveryOptions, IXunitTestMethod testMethod, IFactAttribute factAttribute) { - return CocoaUtilities.CreateTestCase(TestCaseKind.Fact, discoveryOptions, testMethod, factAttribute, null); + return CocoaUtilities.CreateTestCaseForFact(discoveryOptions, testMethod, factAttribute); } } diff --git a/src/Xunit.StaFact/Sdk.Mac/CocoaTheoryDiscoverer.cs b/src/Xunit.StaFact/Sdk.Mac/CocoaTheoryDiscoverer.cs index 4ebec6f4..9628347b 100644 --- a/src/Xunit.StaFact/Sdk.Mac/CocoaTheoryDiscoverer.cs +++ b/src/Xunit.StaFact/Sdk.Mac/CocoaTheoryDiscoverer.cs @@ -11,11 +11,11 @@ public class CocoaTheoryDiscoverer : TheoryDiscoverer /// protected override ValueTask> CreateTestCasesForDataRow(ITestFrameworkDiscoveryOptions discoveryOptions, IXunitTestMethod testMethod, ITheoryAttribute theoryAttribute, ITheoryDataRow dataRow, object?[] testMethodArguments) { - IXunitTestCase testCase = CocoaUtilities.CreateTestCase( - TestCaseKind.DataRow, + IXunitTestCase testCase = CocoaUtilities.CreateTestCaseForDataRow( discoveryOptions, testMethod, theoryAttribute, + dataRow, testMethodArguments); return new([testCase]); } @@ -23,12 +23,10 @@ protected override ValueTask> CreateTestCase /// protected override ValueTask> CreateTestCasesForTheory(ITestFrameworkDiscoveryOptions discoveryOptions, IXunitTestMethod testMethod, ITheoryAttribute theoryAttribute) { - IXunitTestCase testCase = CocoaUtilities.CreateTestCase( - TestCaseKind.DelayEnumerated, + IXunitTestCase testCase = CocoaUtilities.CreateTestCaseForTheory( discoveryOptions, testMethod, - theoryAttribute, - null); + theoryAttribute); return new([testCase]); } } diff --git a/src/Xunit.StaFact/Sdk.Mac/CocoaUtilities.cs b/src/Xunit.StaFact/Sdk.Mac/CocoaUtilities.cs index cd22d9e6..b90afba6 100644 --- a/src/Xunit.StaFact/Sdk.Mac/CocoaUtilities.cs +++ b/src/Xunit.StaFact/Sdk.Mac/CocoaUtilities.cs @@ -5,20 +5,49 @@ namespace Xunit.Sdk; internal static class CocoaUtilities { - internal static IXunitTestCase CreateTestCase( - TestCaseKind kind, + private const UITestCase.SyncContextType ContextType = UITestCase.SyncContextType.Cocoa; + private const string? SkipReason = null; + + internal static IXunitTestCase CreateTestCaseForFact( + ITestFrameworkDiscoveryOptions discoveryOptions, + IXunitTestMethod testMethod, + IFactAttribute factAttribute) + { + return Utilities.CreateTestCaseForFact( + ContextType, + SkipReason, + discoveryOptions, + testMethod, + factAttribute); + } + + internal static IXunitTestCase CreateTestCaseForDataRow( ITestFrameworkDiscoveryOptions discoveryOptions, IXunitTestMethod testMethod, - IFactAttribute theoryAttribute, - object?[]? testMethodArguments) + ITheoryAttribute theoryAttribute, + ITheoryDataRow dataRow, + object?[] testMethodArguments) { - return Utilities.CreateTestCase( - kind, - UITestCase.SyncContextType.Cocoa, - null, + return Utilities.CreateTestCaseForDataRow( + ContextType, + SkipReason, discoveryOptions, testMethod, theoryAttribute, + dataRow, testMethodArguments); } + + internal static IXunitTestCase CreateTestCaseForTheory( + ITestFrameworkDiscoveryOptions discoveryOptions, + IXunitTestMethod testMethod, + ITheoryAttribute theoryAttribute) + { + return Utilities.CreateTestCaseForTheory( + ContextType, + SkipReason, + discoveryOptions, + testMethod, + theoryAttribute); + } } diff --git a/src/Xunit.StaFact/Sdk.WindowsDesktop/WinFormsFactDiscoverer.cs b/src/Xunit.StaFact/Sdk.WindowsDesktop/WinFormsFactDiscoverer.cs index e8a0f59a..5a32f6f6 100644 --- a/src/Xunit.StaFact/Sdk.WindowsDesktop/WinFormsFactDiscoverer.cs +++ b/src/Xunit.StaFact/Sdk.WindowsDesktop/WinFormsFactDiscoverer.cs @@ -11,11 +11,9 @@ public class WinFormsFactDiscoverer : FactDiscoverer /// protected override IXunitTestCase CreateTestCase(ITestFrameworkDiscoveryOptions discoveryOptions, IXunitTestMethod testMethod, IFactAttribute factAttribute) { - return WinFormsUtilities.CreateTestCase( - TestCaseKind.Fact, + return WinFormsUtilities.CreateTestCaseForFact( discoveryOptions, testMethod, - factAttribute, - null); + factAttribute); } } diff --git a/src/Xunit.StaFact/Sdk.WindowsDesktop/WinFormsTheoryDiscoverer.cs b/src/Xunit.StaFact/Sdk.WindowsDesktop/WinFormsTheoryDiscoverer.cs index f6f92cdc..0f37b2ac 100644 --- a/src/Xunit.StaFact/Sdk.WindowsDesktop/WinFormsTheoryDiscoverer.cs +++ b/src/Xunit.StaFact/Sdk.WindowsDesktop/WinFormsTheoryDiscoverer.cs @@ -11,11 +11,11 @@ public class WinFormsTheoryDiscoverer : TheoryDiscoverer /// protected override ValueTask> CreateTestCasesForDataRow(ITestFrameworkDiscoveryOptions discoveryOptions, IXunitTestMethod testMethod, ITheoryAttribute theoryAttribute, ITheoryDataRow dataRow, object?[] testMethodArguments) { - IXunitTestCase testCase = WinFormsUtilities.CreateTestCase( - TestCaseKind.DataRow, + IXunitTestCase testCase = WinFormsUtilities.CreateTestCaseForDataRow( discoveryOptions, testMethod, theoryAttribute, + dataRow, testMethodArguments); return new([testCase]); } @@ -23,12 +23,10 @@ protected override ValueTask> CreateTestCase /// protected override ValueTask> CreateTestCasesForTheory(ITestFrameworkDiscoveryOptions discoveryOptions, IXunitTestMethod testMethod, ITheoryAttribute theoryAttribute) { - IXunitTestCase testCase = WinFormsUtilities.CreateTestCase( - TestCaseKind.DelayEnumerated, + IXunitTestCase testCase = WinFormsUtilities.CreateTestCaseForTheory( discoveryOptions, testMethod, - theoryAttribute, - null); + theoryAttribute); return new([testCase]); } } diff --git a/src/Xunit.StaFact/Sdk.WindowsDesktop/WinFormsUtilities.cs b/src/Xunit.StaFact/Sdk.WindowsDesktop/WinFormsUtilities.cs index c3d06180..c1662f7a 100644 --- a/src/Xunit.StaFact/Sdk.WindowsDesktop/WinFormsUtilities.cs +++ b/src/Xunit.StaFact/Sdk.WindowsDesktop/WinFormsUtilities.cs @@ -7,20 +7,49 @@ namespace Xunit.Sdk; internal static class WinFormsUtilities { - internal static IXunitTestCase CreateTestCase( - TestCaseKind kind, + private const UITestCase.SyncContextType ContextType = UITestCase.SyncContextType.WinForms; + private static readonly string? SkipReason = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? null : "WinForms only exists on Windows."; + + internal static IXunitTestCase CreateTestCaseForFact( + ITestFrameworkDiscoveryOptions discoveryOptions, + IXunitTestMethod testMethod, + IFactAttribute factAttribute) + { + return Utilities.CreateTestCaseForFact( + ContextType, + SkipReason, + discoveryOptions, + testMethod, + factAttribute); + } + + internal static IXunitTestCase CreateTestCaseForDataRow( ITestFrameworkDiscoveryOptions discoveryOptions, IXunitTestMethod testMethod, - IFactAttribute theoryAttribute, - object?[]? testMethodArguments) + ITheoryAttribute theoryAttribute, + ITheoryDataRow dataRow, + object?[] testMethodArguments) { - return Utilities.CreateTestCase( - kind, - UITestCase.SyncContextType.WinForms, - RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? null : "WinForms only exists on Windows.", + return Utilities.CreateTestCaseForDataRow( + ContextType, + SkipReason, discoveryOptions, testMethod, theoryAttribute, + dataRow, testMethodArguments); } + + internal static IXunitTestCase CreateTestCaseForTheory( + ITestFrameworkDiscoveryOptions discoveryOptions, + IXunitTestMethod testMethod, + ITheoryAttribute theoryAttribute) + { + return Utilities.CreateTestCaseForTheory( + ContextType, + SkipReason, + discoveryOptions, + testMethod, + theoryAttribute); + } } diff --git a/src/Xunit.StaFact/Sdk.WindowsDesktop/WpfFactDiscoverer.cs b/src/Xunit.StaFact/Sdk.WindowsDesktop/WpfFactDiscoverer.cs index e92ced4c..6e60e606 100644 --- a/src/Xunit.StaFact/Sdk.WindowsDesktop/WpfFactDiscoverer.cs +++ b/src/Xunit.StaFact/Sdk.WindowsDesktop/WpfFactDiscoverer.cs @@ -1,8 +1,6 @@ // Copyright (c) Andrew Arnott. All rights reserved. // Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. -using System.Runtime.InteropServices; - namespace Xunit.Sdk; /// @@ -13,11 +11,6 @@ public class WpfFactDiscoverer : FactDiscoverer /// protected override IXunitTestCase CreateTestCase(ITestFrameworkDiscoveryOptions discoveryOptions, IXunitTestMethod testMethod, IFactAttribute factAttribute) { - return WpfUtilities.CreateTestCase( - TestCaseKind.Fact, - discoveryOptions, - testMethod, - factAttribute, - null); + return WpfUtilities.CreateTestCaseForFact(discoveryOptions, testMethod, factAttribute); } } diff --git a/src/Xunit.StaFact/Sdk.WindowsDesktop/WpfTheoryDiscoverer.cs b/src/Xunit.StaFact/Sdk.WindowsDesktop/WpfTheoryDiscoverer.cs index 7e7fd1df..63c1981e 100644 --- a/src/Xunit.StaFact/Sdk.WindowsDesktop/WpfTheoryDiscoverer.cs +++ b/src/Xunit.StaFact/Sdk.WindowsDesktop/WpfTheoryDiscoverer.cs @@ -11,11 +11,11 @@ public class WpfTheoryDiscoverer : TheoryDiscoverer /// protected override ValueTask> CreateTestCasesForDataRow(ITestFrameworkDiscoveryOptions discoveryOptions, IXunitTestMethod testMethod, ITheoryAttribute theoryAttribute, ITheoryDataRow dataRow, object?[] testMethodArguments) { - IXunitTestCase testCase = WpfUtilities.CreateTestCase( - TestCaseKind.DataRow, + IXunitTestCase testCase = WpfUtilities.CreateTestCaseForDataRow( discoveryOptions, testMethod, theoryAttribute, + dataRow, testMethodArguments); return new([testCase]); } @@ -23,12 +23,10 @@ protected override ValueTask> CreateTestCase /// protected override ValueTask> CreateTestCasesForTheory(ITestFrameworkDiscoveryOptions discoveryOptions, IXunitTestMethod testMethod, ITheoryAttribute theoryAttribute) { - IXunitTestCase testCase = WpfUtilities.CreateTestCase( - TestCaseKind.DelayEnumerated, + IXunitTestCase testCase = WpfUtilities.CreateTestCaseForTheory( discoveryOptions, testMethod, - theoryAttribute, - null); + theoryAttribute); return new([testCase]); } } diff --git a/src/Xunit.StaFact/Sdk.WindowsDesktop/WpfUtilities.cs b/src/Xunit.StaFact/Sdk.WindowsDesktop/WpfUtilities.cs index d8e40eb3..24ee960d 100644 --- a/src/Xunit.StaFact/Sdk.WindowsDesktop/WpfUtilities.cs +++ b/src/Xunit.StaFact/Sdk.WindowsDesktop/WpfUtilities.cs @@ -7,20 +7,49 @@ namespace Xunit.Sdk; internal static class WpfUtilities { - internal static IXunitTestCase CreateTestCase( - TestCaseKind kind, + private const UITestCase.SyncContextType ContextType = UITestCase.SyncContextType.WPF; + private static readonly string? SkipReason = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? null : "WPF only exists on Windows."; + + internal static IXunitTestCase CreateTestCaseForFact( + ITestFrameworkDiscoveryOptions discoveryOptions, + IXunitTestMethod testMethod, + IFactAttribute factAttribute) + { + return Utilities.CreateTestCaseForFact( + ContextType, + SkipReason, + discoveryOptions, + testMethod, + factAttribute); + } + + internal static IXunitTestCase CreateTestCaseForDataRow( ITestFrameworkDiscoveryOptions discoveryOptions, IXunitTestMethod testMethod, - IFactAttribute theoryAttribute, - object?[]? testMethodArguments) + ITheoryAttribute theoryAttribute, + ITheoryDataRow dataRow, + object?[] testMethodArguments) { - return Utilities.CreateTestCase( - kind, - UITestCase.SyncContextType.WPF, - RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? null : "WPF only exists on Windows.", + return Utilities.CreateTestCaseForDataRow( + ContextType, + SkipReason, discoveryOptions, testMethod, theoryAttribute, + dataRow, testMethodArguments); } + + internal static IXunitTestCase CreateTestCaseForTheory( + ITestFrameworkDiscoveryOptions discoveryOptions, + IXunitTestMethod testMethod, + ITheoryAttribute theoryAttribute) + { + return Utilities.CreateTestCaseForTheory( + ContextType, + SkipReason, + discoveryOptions, + testMethod, + theoryAttribute); + } } diff --git a/src/Xunit.StaFact/Sdk/StaFactDiscoverer.cs b/src/Xunit.StaFact/Sdk/StaFactDiscoverer.cs index 5625ce57..3679dd4a 100644 --- a/src/Xunit.StaFact/Sdk/StaFactDiscoverer.cs +++ b/src/Xunit.StaFact/Sdk/StaFactDiscoverer.cs @@ -11,6 +11,6 @@ public class StaFactDiscoverer : FactDiscoverer /// protected override IXunitTestCase CreateTestCase(ITestFrameworkDiscoveryOptions discoveryOptions, IXunitTestMethod testMethod, IFactAttribute factAttribute) { - return StaUtilities.CreateTestCase(TestCaseKind.Fact, discoveryOptions, testMethod, factAttribute, null); + return StaUtilities.CreateTestCaseForFact(discoveryOptions, testMethod, factAttribute); } } diff --git a/src/Xunit.StaFact/Sdk/StaTheoryDiscoverer.cs b/src/Xunit.StaFact/Sdk/StaTheoryDiscoverer.cs index 49e19e2b..77d53c09 100644 --- a/src/Xunit.StaFact/Sdk/StaTheoryDiscoverer.cs +++ b/src/Xunit.StaFact/Sdk/StaTheoryDiscoverer.cs @@ -11,11 +11,11 @@ public class StaTheoryDiscoverer : TheoryDiscoverer /// protected override ValueTask> CreateTestCasesForDataRow(ITestFrameworkDiscoveryOptions discoveryOptions, IXunitTestMethod testMethod, ITheoryAttribute theoryAttribute, ITheoryDataRow dataRow, object?[] testMethodArguments) { - IXunitTestCase testCase = StaUtilities.CreateTestCase( - TestCaseKind.DataRow, + IXunitTestCase testCase = StaUtilities.CreateTestCaseForDataRow( discoveryOptions, testMethod, theoryAttribute, + dataRow, testMethodArguments); return new([testCase]); } @@ -23,12 +23,10 @@ protected override ValueTask> CreateTestCase /// protected override ValueTask> CreateTestCasesForTheory(ITestFrameworkDiscoveryOptions discoveryOptions, IXunitTestMethod testMethod, ITheoryAttribute theoryAttribute) { - IXunitTestCase testCase = StaUtilities.CreateTestCase( - TestCaseKind.DelayEnumerated, + IXunitTestCase testCase = StaUtilities.CreateTestCaseForTheory( discoveryOptions, testMethod, - theoryAttribute, - null); + theoryAttribute); return new([testCase]); } } diff --git a/src/Xunit.StaFact/Sdk/StaUtilities.cs b/src/Xunit.StaFact/Sdk/StaUtilities.cs index 2be30c0b..1b166128 100644 --- a/src/Xunit.StaFact/Sdk/StaUtilities.cs +++ b/src/Xunit.StaFact/Sdk/StaUtilities.cs @@ -7,20 +7,49 @@ namespace Xunit.Sdk; internal static class StaUtilities { - internal static IXunitTestCase CreateTestCase( - TestCaseKind kind, + private const UITestCase.SyncContextType ContextType = UITestCase.SyncContextType.None; + private static readonly string? SkipReason = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? null : "STA threads only exist on Windows."; + + internal static IXunitTestCase CreateTestCaseForFact( + ITestFrameworkDiscoveryOptions discoveryOptions, + IXunitTestMethod testMethod, + IFactAttribute factAttribute) + { + return Utilities.CreateTestCaseForFact( + ContextType, + SkipReason, + discoveryOptions, + testMethod, + factAttribute); + } + + internal static IXunitTestCase CreateTestCaseForDataRow( ITestFrameworkDiscoveryOptions discoveryOptions, IXunitTestMethod testMethod, - IFactAttribute theoryAttribute, - object?[]? testMethodArguments) + ITheoryAttribute theoryAttribute, + ITheoryDataRow dataRow, + object?[] testMethodArguments) { - return Utilities.CreateTestCase( - kind, - UITestCase.SyncContextType.None, - RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? null : "STA threads only exist on Windows.", + return Utilities.CreateTestCaseForDataRow( + ContextType, + SkipReason, discoveryOptions, testMethod, theoryAttribute, + dataRow, testMethodArguments); } + + internal static IXunitTestCase CreateTestCaseForTheory( + ITestFrameworkDiscoveryOptions discoveryOptions, + IXunitTestMethod testMethod, + ITheoryAttribute theoryAttribute) + { + return Utilities.CreateTestCaseForTheory( + ContextType, + SkipReason, + discoveryOptions, + testMethod, + theoryAttribute); + } } diff --git a/src/Xunit.StaFact/Sdk/TestCaseKind.cs b/src/Xunit.StaFact/Sdk/TestCaseKind.cs deleted file mode 100644 index 60843857..00000000 --- a/src/Xunit.StaFact/Sdk/TestCaseKind.cs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (c) Andrew Arnott. All rights reserved. -// Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. - -namespace Xunit.Sdk; - -internal enum TestCaseKind -{ - Fact, - DataRow, - DelayEnumerated, -} diff --git a/src/Xunit.StaFact/Sdk/UIFactDiscoverer.cs b/src/Xunit.StaFact/Sdk/UIFactDiscoverer.cs index 3e60d753..aef56144 100644 --- a/src/Xunit.StaFact/Sdk/UIFactDiscoverer.cs +++ b/src/Xunit.StaFact/Sdk/UIFactDiscoverer.cs @@ -11,6 +11,6 @@ public class UIFactDiscoverer : FactDiscoverer /// protected override IXunitTestCase CreateTestCase(ITestFrameworkDiscoveryOptions discoveryOptions, IXunitTestMethod testMethod, IFactAttribute factAttribute) { - return UIUtilities.CreateTestCase(TestCaseKind.Fact, discoveryOptions, testMethod, factAttribute, null); + return UIUtilities.CreateTestCaseForFact(discoveryOptions, testMethod, factAttribute); } } diff --git a/src/Xunit.StaFact/Sdk/UITheoryDiscoverer.cs b/src/Xunit.StaFact/Sdk/UITheoryDiscoverer.cs index 2100dbda..e9ccf236 100644 --- a/src/Xunit.StaFact/Sdk/UITheoryDiscoverer.cs +++ b/src/Xunit.StaFact/Sdk/UITheoryDiscoverer.cs @@ -11,11 +11,11 @@ public class UITheoryDiscoverer : TheoryDiscoverer /// protected override ValueTask> CreateTestCasesForDataRow(ITestFrameworkDiscoveryOptions discoveryOptions, IXunitTestMethod testMethod, ITheoryAttribute theoryAttribute, ITheoryDataRow dataRow, object?[] testMethodArguments) { - IXunitTestCase testCase = UIUtilities.CreateTestCase( - TestCaseKind.DataRow, + IXunitTestCase testCase = UIUtilities.CreateTestCaseForDataRow( discoveryOptions, testMethod, theoryAttribute, + dataRow, testMethodArguments); return new([testCase]); } @@ -23,12 +23,10 @@ protected override ValueTask> CreateTestCase /// protected override ValueTask> CreateTestCasesForTheory(ITestFrameworkDiscoveryOptions discoveryOptions, IXunitTestMethod testMethod, ITheoryAttribute theoryAttribute) { - IXunitTestCase testCase = UIUtilities.CreateTestCase( - TestCaseKind.DelayEnumerated, + IXunitTestCase testCase = UIUtilities.CreateTestCaseForTheory( discoveryOptions, testMethod, - theoryAttribute, - null); + theoryAttribute); return new([testCase]); } } diff --git a/src/Xunit.StaFact/Sdk/UIUtilities.cs b/src/Xunit.StaFact/Sdk/UIUtilities.cs index 163c05ec..d7c23088 100644 --- a/src/Xunit.StaFact/Sdk/UIUtilities.cs +++ b/src/Xunit.StaFact/Sdk/UIUtilities.cs @@ -5,20 +5,49 @@ namespace Xunit.Sdk; internal static class UIUtilities { - internal static IXunitTestCase CreateTestCase( - TestCaseKind kind, + private const UITestCase.SyncContextType ContextType = UITestCase.SyncContextType.Portable; + private const string? SkipReason = null; + + internal static IXunitTestCase CreateTestCaseForFact( + ITestFrameworkDiscoveryOptions discoveryOptions, + IXunitTestMethod testMethod, + IFactAttribute factAttribute) + { + return Utilities.CreateTestCaseForFact( + ContextType, + SkipReason, + discoveryOptions, + testMethod, + factAttribute); + } + + internal static IXunitTestCase CreateTestCaseForDataRow( ITestFrameworkDiscoveryOptions discoveryOptions, IXunitTestMethod testMethod, - IFactAttribute factAttribute, - object?[]? testMethodArguments) + ITheoryAttribute theoryAttribute, + ITheoryDataRow dataRow, + object?[] testMethodArguments) { - return Utilities.CreateTestCase( - kind, - UITestCase.SyncContextType.Portable, - null, + return Utilities.CreateTestCaseForDataRow( + ContextType, + SkipReason, discoveryOptions, testMethod, - factAttribute, + theoryAttribute, + dataRow, testMethodArguments); } + + internal static IXunitTestCase CreateTestCaseForTheory( + ITestFrameworkDiscoveryOptions discoveryOptions, + IXunitTestMethod testMethod, + ITheoryAttribute theoryAttribute) + { + return Utilities.CreateTestCaseForTheory( + ContextType, + SkipReason, + discoveryOptions, + testMethod, + theoryAttribute); + } } diff --git a/src/Xunit.StaFact/Sdk/Utilities.cs b/src/Xunit.StaFact/Sdk/Utilities.cs index 2cbfbc07..9de37103 100644 --- a/src/Xunit.StaFact/Sdk/Utilities.cs +++ b/src/Xunit.StaFact/Sdk/Utilities.cs @@ -8,22 +8,18 @@ namespace Xunit.Sdk; internal static class Utilities { - internal static IXunitTestCase CreateTestCase( - TestCaseKind kind, + internal static IXunitTestCase CreateTestCaseForFact( UITestCase.SyncContextType synchronizationContextType, string? skipReason, ITestFrameworkDiscoveryOptions discoveryOptions, IXunitTestMethod testMethod, - IFactAttribute attribute, - object?[]? testMethodArguments) + IFactAttribute factAttribute) { (string TestCaseDisplayName, bool Explicit, string? SkipReason, Type? SkipType, string? SkipUnless, string? SkipWhen, int Timeout, string UniqueID, IXunitTestMethod ResolvedTestMethod) details; Dictionary> traits; - UISettingsAttribute settings; - details = TestIntrospectionHelper.GetTestCaseDetails(discoveryOptions, testMethod, attribute); - settings = GetSettings(testMethod); - traits = testMethod.Traits.ToReadWrite(StringComparer.OrdinalIgnoreCase); + details = TestIntrospectionHelper.GetTestCaseDetails(discoveryOptions, testMethod, factAttribute); + traits = GetTraits(testMethod); if (skipReason is not null) { @@ -33,35 +29,53 @@ internal static IXunitTestCase CreateTestCase( details.UniqueID, details.Explicit, skipReason, - traits, - testMethodArguments); + traits); } - if (kind == TestCaseKind.DelayEnumerated) + return new UITestCase( + GetSettings(testMethod), + synchronizationContextType, + details.ResolvedTestMethod, + details.TestCaseDisplayName, + details.UniqueID, + details.Explicit, + details.SkipReason, + details.SkipType, + details.SkipUnless, + details.SkipWhen, + traits, + timeout: details.Timeout); + } + + internal static IXunitTestCase CreateTestCaseForDataRow( + UITestCase.SyncContextType synchronizationContextType, + string? skipReason, + ITestFrameworkDiscoveryOptions discoveryOptions, + IXunitTestMethod testMethod, + ITheoryAttribute theoryAttribute, + ITheoryDataRow dataRow, + object?[] testMethodArguments) + { + (string TestCaseDisplayName, bool Explicit, string? SkipReason, Type? SkipType, string? SkipUnless, string? SkipWhen, int Timeout, string UniqueID, IXunitTestMethod ResolvedTestMethod) details; + Dictionary> traits; + + details = TestIntrospectionHelper.GetTestCaseDetailsForTheoryDataRow(discoveryOptions, testMethod, theoryAttribute, dataRow, testMethodArguments); + traits = GetTraits(testMethod); + + if (skipReason is not null) { - return new UIDelayEnumeratedTestCase( - settings, - synchronizationContextType, - details.ResolvedTestMethod, - details.TestCaseDisplayName, - details.UniqueID, - details.Explicit, - (attribute as ITheoryAttribute)?.SkipTestWithoutData ?? false, - details.SkipReason, - details.SkipType, - details.SkipUnless, - details.SkipWhen, - traits, - timeout: details.Timeout); + return new SkippedTestCase( + details.ResolvedTestMethod, + details.TestCaseDisplayName, + details.UniqueID, + details.Explicit, + skipReason, + traits, + testMethodArguments); } - // Fact and DataRow test case kinds both result in a UITestCase. - // The only difference is that DataRow should have test method - // arguments, and Fact should not. The caller should pass null - // for the test method arguments when the test case kind is Fact, - // so we can use the same code path for both kinds. return new UITestCase( - settings, + GetSettings(testMethod), synchronizationContextType, details.ResolvedTestMethod, details.TestCaseDisplayName, @@ -76,8 +90,53 @@ internal static IXunitTestCase CreateTestCase( timeout: details.Timeout); } + internal static IXunitTestCase CreateTestCaseForTheory( + UITestCase.SyncContextType synchronizationContextType, + string? skipReason, + ITestFrameworkDiscoveryOptions discoveryOptions, + IXunitTestMethod testMethod, + ITheoryAttribute attribute) + { + (string TestCaseDisplayName, bool Explicit, string? SkipReason, Type? SkipType, string? SkipUnless, string? SkipWhen, int Timeout, string UniqueID, IXunitTestMethod ResolvedTestMethod) details; + Dictionary> traits; + + details = TestIntrospectionHelper.GetTestCaseDetails(discoveryOptions, testMethod, attribute); + traits = GetTraits(testMethod); + + if (skipReason is not null) + { + return new SkippedTestCase( + details.ResolvedTestMethod, + details.TestCaseDisplayName, + details.UniqueID, + details.Explicit, + skipReason, + traits); + } + + return new UIDelayEnumeratedTestCase( + GetSettings(testMethod), + synchronizationContextType, + details.ResolvedTestMethod, + details.TestCaseDisplayName, + details.UniqueID, + details.Explicit, + attribute.SkipTestWithoutData, + details.SkipReason, + details.SkipType, + details.SkipUnless, + details.SkipWhen, + traits, + timeout: details.Timeout); + } + internal static SyncContextAwaiter GetAwaiter(this SynchronizationContext synchronizationContext) => new SyncContextAwaiter(synchronizationContext); + private static Dictionary> GetTraits(IXunitTestMethod testMethod) + { + return testMethod.Traits.ToReadWrite(StringComparer.OrdinalIgnoreCase); + } + private static UISettingsAttribute GetSettings(IXunitTestMethod testMethod) { // Initialize with defaults. From c56047b4edabac1bb49d464b757d639469422210 Mon Sep 17 00:00:00 2001 From: reduckted Date: Sat, 18 Jan 2025 21:02:40 +1000 Subject: [PATCH 26/27] Fixed Mac tests not running --- Directory.Packages.props | 1 - test/Xunit.StaFact.Tests.Mac/AppDelegate.cs | 11 ++------ .../Directory.Build.targets | 20 +++++++++++++ .../Xunit.StaFact.Tests.Mac.csproj | 28 ++++++++----------- 4 files changed, 35 insertions(+), 25 deletions(-) create mode 100644 test/Xunit.StaFact.Tests.Mac/Directory.Build.targets diff --git a/Directory.Packages.props b/Directory.Packages.props index b088239e..300d2785 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -8,7 +8,6 @@ - diff --git a/test/Xunit.StaFact.Tests.Mac/AppDelegate.cs b/test/Xunit.StaFact.Tests.Mac/AppDelegate.cs index 8ab08124..94f2b025 100644 --- a/test/Xunit.StaFact.Tests.Mac/AppDelegate.cs +++ b/test/Xunit.StaFact.Tests.Mac/AppDelegate.cs @@ -2,6 +2,7 @@ // Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. using System.Runtime.InteropServices; +using Xunit.Runner.InProc.SystemConsole; namespace Xunit.StaFact.Tests.Mac; @@ -21,13 +22,7 @@ public AppDelegate() public override void DidFinishLaunching(NSNotification notification) { - // Disable AppDomain support since we need all tests to run - // in the main app domain to be able to run on or dispatch to - // the main thread. - this.unitTestDriverArguments.Add("-appdomains"); - this.unitTestDriverArguments.Add("denied"); - - // We also cannot run tests in parallel since our tests depend + // We cannot run tests in parallel since our tests depend // on ordered execution on the main thread. this.unitTestDriverArguments.Add("-parallel"); this.unitTestDriverArguments.Add("none"); @@ -36,7 +31,7 @@ public override void DidFinishLaunching(NSNotification notification) ThreadPool.QueueUserWorkItem(o => { - var exitCode = Xunit.ConsoleClient.Program.Main(args); + var exitCode = ConsoleRunner.Run(args).GetAwaiter().GetResult(); _exit(exitCode); }); } diff --git a/test/Xunit.StaFact.Tests.Mac/Directory.Build.targets b/test/Xunit.StaFact.Tests.Mac/Directory.Build.targets new file mode 100644 index 00000000..29fca497 --- /dev/null +++ b/test/Xunit.StaFact.Tests.Mac/Directory.Build.targets @@ -0,0 +1,20 @@ + + + + + + + + <_AppExePath>$(PartialTargetPath)\Xunit.StaFact.Tests.Mac.app\Contents\MacOS\Xunit.StaFact.Tests.Mac + + + + diff --git a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj index 0f19e957..20ff62e0 100644 --- a/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj +++ b/test/Xunit.StaFact.Tests.Mac/Xunit.StaFact.Tests.Mac.csproj @@ -1,4 +1,4 @@ - + net8.0-macos Exe @@ -8,32 +8,28 @@ $(HostArchitecture.ToLower()) $(RepoRootPath)\bin\Xunit.StaFact.Tests.Mac\$(Configuration)\$(TargetFramework)\osx-$(HostArchitecture) $(PartialTargetPath)\Xunit.StaFact.Tests.Mac.dll + + + false + + + false + - - - - - - - - <_AppExePath>$(PartialTargetPath)\Xunit.StaFact.Tests.Mac.app\Contents\MacOS\Xunit.StaFact.Tests.Mac - - - - + From 8825e3567782fe0ffe1beb6cc5aac61a3ff09c4e Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sat, 18 Jan 2025 07:43:01 -0700 Subject: [PATCH 27/27] Capture logs from running tests --- .github/workflows/build.yml | 2 +- test/Xunit.StaFact.Tests.Mac/Directory.Build.targets | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 15c4a448..aa5d8aea 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -51,7 +51,7 @@ jobs: run: tools/dotnet-test-cloud.ps1 -Configuration ${{ env.BUILDCONFIGURATION }} -Agent ${{ runner.os }} shell: pwsh - name: 🧪 mac-specific test - run: dotnet build -c ${{ env.BUILDCONFIGURATION }} -t:Test -p:BuildProjectReferences=false + run: dotnet build -c ${{ env.BUILDCONFIGURATION }} -t:Test -p:BuildProjectReferences=false -p:TestLogs="${{ runner.temp }}/_artifacts/test_logs/" -bl:"${{ runner.temp }}/_artifacts/build_logs/macos-test.binlog" working-directory: test/Xunit.StaFact.Tests.Mac if: success() && runner.os == 'macos' - name: 💅🏻 Verify formatted code diff --git a/test/Xunit.StaFact.Tests.Mac/Directory.Build.targets b/test/Xunit.StaFact.Tests.Mac/Directory.Build.targets index 29fca497..fffd4308 100644 --- a/test/Xunit.StaFact.Tests.Mac/Directory.Build.targets +++ b/test/Xunit.StaFact.Tests.Mac/Directory.Build.targets @@ -13,8 +13,10 @@ --> - <_AppExePath>$(PartialTargetPath)\Xunit.StaFact.Tests.Mac.app\Contents\MacOS\Xunit.StaFact.Tests.Mac + <_AppExePath>$(PartialTargetPath)/Xunit.StaFact.Tests.Mac.app/Contents/MacOS/Xunit.StaFact.Tests.Mac + <_TestLogs>$(TestLogs) + <_TestLogs Condition="'$(_TestLogs)'==''">$(RepoRootPath)test_logs/ - +