diff --git a/ExcelDna.Testing/Directory.Build.targets b/ExcelDna.Testing/Directory.Build.targets index 5ece0e3..3c8788e 100644 --- a/ExcelDna.Testing/Directory.Build.targets +++ b/ExcelDna.Testing/Directory.Build.targets @@ -1,7 +1,7 @@ - - + + diff --git a/ExcelDna.Testing/ExampleAddinNET8/ExampleAddinNET8.csproj b/ExcelDna.Testing/ExampleAddinNET8/ExampleAddinNET8.csproj index 7b92564..d6bcf20 100644 --- a/ExcelDna.Testing/ExampleAddinNET8/ExampleAddinNET8.csproj +++ b/ExcelDna.Testing/ExampleAddinNET8/ExampleAddinNET8.csproj @@ -2,6 +2,7 @@ net8.0-windows + LatestMajor enable enable diff --git a/ExcelDna.Testing/Examples/Examples.csproj b/ExcelDna.Testing/Examples/Examples.csproj index e197164..ff000d0 100644 --- a/ExcelDna.Testing/Examples/Examples.csproj +++ b/ExcelDna.Testing/Examples/Examples.csproj @@ -4,12 +4,13 @@ net472;net6.0-windows true true + Exe - + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -34,7 +35,7 @@ - + diff --git a/ExcelDna.Testing/ExcelDna.Testing/ExcelDna.Testing.csproj b/ExcelDna.Testing/ExcelDna.Testing/ExcelDna.Testing.csproj index 75e91e9..bb1618e 100644 --- a/ExcelDna.Testing/ExcelDna.Testing/ExcelDna.Testing.csproj +++ b/ExcelDna.Testing/ExcelDna.Testing/ExcelDna.Testing.csproj @@ -2,6 +2,7 @@ net472;net6.0-windows + 9.0 true true @@ -12,7 +13,7 @@ - + \ No newline at end of file diff --git a/ExcelDna.Testing/ExcelDna.Testing/ExcelFactAttribute.cs b/ExcelDna.Testing/ExcelDna.Testing/ExcelFactAttribute.cs index 9f79b7b..4a9cae3 100644 --- a/ExcelDna.Testing/ExcelDna.Testing/ExcelFactAttribute.cs +++ b/ExcelDna.Testing/ExcelDna.Testing/ExcelFactAttribute.cs @@ -1,11 +1,11 @@ using System; -using Xunit.Sdk; using ExcelDna.Testing; +using Xunit.v3; namespace Xunit { [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] - [XunitTestCaseDiscoverer("ExcelDna.Testing." + nameof(ExcelFactDiscoverer), "ExcelDna.Testing")] + [XunitTestCaseDiscoverer(typeof(ExcelFactDiscoverer))] public class ExcelFactAttribute : FactAttribute, ITestSettings { /// diff --git a/ExcelDna.Testing/ExcelDna.Testing/ExcelFactDiscoverer.cs b/ExcelDna.Testing/ExcelDna.Testing/ExcelFactDiscoverer.cs index a7d24c9..ae92d46 100644 --- a/ExcelDna.Testing/ExcelDna.Testing/ExcelFactDiscoverer.cs +++ b/ExcelDna.Testing/ExcelDna.Testing/ExcelFactDiscoverer.cs @@ -1,54 +1,55 @@ using System.Collections.Generic; using Xunit; -using Xunit.Abstractions; using Xunit.Sdk; -using System.Linq; +using Xunit.v3; +using System.Threading.Tasks; +using System.Reflection; +using System; +using Xunit.Internal; namespace ExcelDna.Testing { class ExcelFactDiscoverer : FactDiscoverer { - public ExcelFactDiscoverer(IMessageSink diagnosticMessageSink) : base(diagnosticMessageSink) + public ExcelFactDiscoverer(IMessageSink diagnosticMessageSink) { } - public override IEnumerable Discover(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute) + public override ValueTask> Discover(ITestFrameworkDiscoveryOptions discoveryOptions, IXunitTestMethod testMethod, IFactAttribute factAttribute) { - var results = new List(); - results.Add(new ExcelTestCase(GetSettings(testMethod), DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod, null)); - return results; + var details = TestIntrospectionHelper.GetTestCaseDetails(discoveryOptions, testMethod, factAttribute); + IXunitTestCase testCase = new ExcelTestCase(GetSettings(testMethod), + details.ResolvedTestMethod, + details.TestCaseDisplayName, + details.UniqueID, + details.Explicit, + details.SkipExceptions, + details.SkipReason, + details.SkipType, + details.SkipUnless, + details.SkipWhen, + testMethod.Traits.ToReadWrite(StringComparer.OrdinalIgnoreCase), + sourceFilePath: details.SourceFilePath, + sourceLineNumber: details.SourceLineNumber, + timeout: details.Timeout); + + return new(new IXunitTestCase[] { testCase }); } - private static ExcelTestSettings GetSettings(ITestMethod testMethod) + private static ExcelTestSettings GetSettings(IXunitTestMethod testMethod) { - return new ExcelTestSettings( - GetSetting(testMethod, nameof(ExcelFactAttribute.OutOfProcess)), - GetSetting(testMethod, nameof(ExcelFactAttribute.Workbook)), - GetSetting(testMethod, nameof(ExcelFactAttribute.AddIn))); - } - - private static T GetSetting(ITestMethod testMethod, string name) - { - object arg = GetNamedArg(testMethod.Method.GetCustomAttributes(typeof(ExcelFactAttribute)).FirstOrDefault(), name); - if (arg == null) - arg = GetNamedArg(testMethod.TestClass.Class.GetCustomAttributes(typeof(ExcelTestSettingsAttribute)).FirstOrDefault(), name); - - return arg is T ? (T)arg : default(T); - } - - private static object GetNamedArg(IAttributeInfo attributeInfo, string argumentName) - { - if (!IsNamedArg(attributeInfo, argumentName)) - return null; - - return attributeInfo.GetNamedArgument(argumentName); - } - - private static bool IsNamedArg(IAttributeInfo attributeInfo, string argumentName) - { - if (attributeInfo is ReflectionAttributeInfo reflectionAttributeInfo) - return reflectionAttributeInfo.AttributeData.NamedArguments.Any(arg => arg.MemberName == argumentName); - return false; + { + ExcelFactAttribute attr = testMethod.Method.GetCustomAttribute(); + if (attr != null) + return new ExcelTestSettings(attr.OutOfProcess, attr.Workbook, attr.AddIn); + } + { + ExcelTestSettingsAttribute attr = testMethod.Method.GetCustomAttribute(); + if (attr != null) + return new ExcelTestSettings(attr.OutOfProcess, attr.Workbook, attr.AddIn); + } + + return new ExcelTestSettings(false, null, null); } } } diff --git a/ExcelDna.Testing/ExcelDna.Testing/ExcelTestAssemblyRunner.cs b/ExcelDna.Testing/ExcelDna.Testing/ExcelTestAssemblyRunner.cs index 6cf44e0..7312694 100644 --- a/ExcelDna.Testing/ExcelDna.Testing/ExcelTestAssemblyRunner.cs +++ b/ExcelDna.Testing/ExcelDna.Testing/ExcelTestAssemblyRunner.cs @@ -8,9 +8,8 @@ using System.Runtime.InteropServices; using System.Threading; using System.Threading.Tasks; -using Xunit; -using Xunit.Abstractions; using Xunit.Sdk; +using Xunit.v3; namespace ExcelDna.Testing { diff --git a/ExcelDna.Testing/ExcelDna.Testing/ExcelTestCase.cs b/ExcelDna.Testing/ExcelDna.Testing/ExcelTestCase.cs index 98b004d..9db4c55 100644 --- a/ExcelDna.Testing/ExcelDna.Testing/ExcelTestCase.cs +++ b/ExcelDna.Testing/ExcelDna.Testing/ExcelTestCase.cs @@ -2,14 +2,14 @@ using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; -using Xunit.Abstractions; using Xunit.Internal; using Xunit.Sdk; +using Xunit.v3; namespace ExcelDna.Testing { [Newtonsoft.Json.JsonConverter(typeof(Remote.ExcelTestCaseConverter))] - public class ExcelTestCase : XunitTestCase + public class ExcelTestCase : XunitTestCase, ISelfExecutingXunitTestCase { [Obsolete("Called by the de-serializer; should only be called by deriving classes for de-serialization purposes")] public ExcelTestCase() @@ -17,8 +17,24 @@ public ExcelTestCase() } #pragma warning disable CS0618 - public ExcelTestCase(ExcelTestSettings testSettings, IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, ITestMethod testMethod, object[] testMethodArguments = null) - : base(diagnosticMessageSink, defaultMethodDisplay, testMethod, testMethodArguments) + public ExcelTestCase(ExcelTestSettings testSettings, + IXunitTestMethod testMethod, + string testCaseDisplayName, + string uniqueID, + bool @explicit, + Type[]? skipExceptions = null, + 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, skipExceptions, skipReason, + skipType, skipUnless, skipWhen, traits, testMethodArguments, sourceFilePath, + sourceLineNumber, timeout) { this.testSettings = testSettings; } @@ -26,8 +42,10 @@ public ExcelTestCase(ExcelTestSettings testSettings, IMessageSink diagnosticMess public ExcelTestSettings Settings => testSettings; - public override Task RunAsync(IMessageSink diagnosticMessageSink, IMessageBus messageBus, object[] constructorArguments, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource) - => new ExcelTestCaseRunner(this, DisplayName, SkipReason, constructorArguments, TestMethodArguments, messageBus, aggregator, cancellationTokenSource).RunAsync(); + public ValueTask Run(ExplicitOption explicitOption, IMessageBus messageBus, object[] constructorArguments, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource, ParallelMode parallelMode, ExecutionScheduler scheduler, FixtureMappingManager methodFixtureMappings) + { + return new ExcelTestCaseRunner(this, TestCaseDisplayName, SkipReason, constructorArguments, TestMethodArguments, messageBus, aggregator, cancellationTokenSource).RunAsync(); + } public override void Serialize(IXunitSerializationInfo info) { diff --git a/ExcelDna.Testing/ExcelDna.Testing/ExcelTestCaseRunner.cs b/ExcelDna.Testing/ExcelDna.Testing/ExcelTestCaseRunner.cs index 35806e4..f1819fe 100644 --- a/ExcelDna.Testing/ExcelDna.Testing/ExcelTestCaseRunner.cs +++ b/ExcelDna.Testing/ExcelDna.Testing/ExcelTestCaseRunner.cs @@ -2,8 +2,8 @@ using System.Collections.Generic; using System.Reflection; using System.Threading; -using Xunit.Abstractions; using Xunit.Sdk; +using Xunit.v3; namespace ExcelDna.Testing { diff --git a/ExcelDna.Testing/ExcelDna.Testing/ExcelTestFramework.cs b/ExcelDna.Testing/ExcelDna.Testing/ExcelTestFramework.cs index 6c50b44..ad2a866 100644 --- a/ExcelDna.Testing/ExcelDna.Testing/ExcelTestFramework.cs +++ b/ExcelDna.Testing/ExcelDna.Testing/ExcelTestFramework.cs @@ -1,9 +1,7 @@ using System.Reflection; -using Xunit.Abstractions; using Xunit.Sdk; using ExcelDna.Testing; - - +using Xunit.v3; namespace Xunit { diff --git a/ExcelDna.Testing/ExcelDna.Testing/ExcelTestFrameworkExecutor.cs b/ExcelDna.Testing/ExcelDna.Testing/ExcelTestFrameworkExecutor.cs index 65f7af6..d7ad386 100644 --- a/ExcelDna.Testing/ExcelDna.Testing/ExcelTestFrameworkExecutor.cs +++ b/ExcelDna.Testing/ExcelDna.Testing/ExcelTestFrameworkExecutor.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using System.Reflection; -using Xunit.Abstractions; using Xunit.Sdk; +using Xunit.v3; namespace ExcelDna.Testing { diff --git a/ExcelDna.Testing/ExcelDna.Testing/ExcelTestRunner.cs b/ExcelDna.Testing/ExcelDna.Testing/ExcelTestRunner.cs index b7f396e..9b76951 100644 --- a/ExcelDna.Testing/ExcelDna.Testing/ExcelTestRunner.cs +++ b/ExcelDna.Testing/ExcelDna.Testing/ExcelTestRunner.cs @@ -5,10 +5,8 @@ using System.Reflection; using System.Threading; using System.Threading.Tasks; -using System.Windows; -using System.Windows.Threading; -using Xunit.Abstractions; using Xunit.Sdk; +using Xunit.v3; namespace ExcelDna.Testing { diff --git a/ExcelDna.Testing/ExcelDna.Testing/Remote/BusMessageEventArgs.cs b/ExcelDna.Testing/ExcelDna.Testing/Remote/BusMessageEventArgs.cs index 0f5c641..b932935 100644 --- a/ExcelDna.Testing/ExcelDna.Testing/Remote/BusMessageEventArgs.cs +++ b/ExcelDna.Testing/ExcelDna.Testing/Remote/BusMessageEventArgs.cs @@ -1,6 +1,6 @@ using System; -using Xunit.Abstractions; using Xunit.Sdk; +using Xunit.v3; namespace ExcelDna.Testing.Remote { diff --git a/ExcelDna.Testing/ExcelDna.Testing/Remote/Converters.cs b/ExcelDna.Testing/ExcelDna.Testing/Remote/Converters.cs index 37aa66f..2f7db6a 100644 --- a/ExcelDna.Testing/ExcelDna.Testing/Remote/Converters.cs +++ b/ExcelDna.Testing/ExcelDna.Testing/Remote/Converters.cs @@ -1,5 +1,6 @@ using Newtonsoft.Json; using System; +using Xunit.Sdk; namespace ExcelDna.Testing.Remote { @@ -42,7 +43,7 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist public override bool CanConvert(Type objectType) { - return objectType == typeof(Xunit.Abstractions.ITestCase) || objectType == typeof(Xunit.Sdk.IXunitTestCase); + return objectType == typeof(ITestCase) || objectType == typeof(Xunit.Sdk.IXunitTestCase); } } @@ -65,7 +66,7 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist public override bool CanConvert(Type objectType) { - return objectType == typeof(Xunit.Abstractions.IAssemblyInfo) || objectType == typeof(Xunit.Sdk.ReflectionAssemblyInfo); + return objectType == typeof(IAssemblyInfo) || objectType == typeof(Xunit.Sdk.ReflectionAssemblyInfo); } } @@ -88,7 +89,7 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist public override bool CanConvert(Type objectType) { - return objectType == typeof(Xunit.Sdk.ReflectionTypeInfo) || objectType == typeof(Xunit.Abstractions.ITypeInfo); + return objectType == typeof(Xunit.Sdk.ReflectionTypeInfo) || objectType == typeof(ITypeInfo); } } } diff --git a/ExcelDna.Testing/ExcelDna.Testing/Remote/MessageBusProxy.cs b/ExcelDna.Testing/ExcelDna.Testing/Remote/MessageBusProxy.cs index 37f12f5..743f30c 100644 --- a/ExcelDna.Testing/ExcelDna.Testing/Remote/MessageBusProxy.cs +++ b/ExcelDna.Testing/ExcelDna.Testing/Remote/MessageBusProxy.cs @@ -1,5 +1,5 @@ -using Xunit.Abstractions; -using Xunit.Sdk; +using Xunit.Sdk; +using Xunit.v3; namespace ExcelDna.Testing.Remote { diff --git a/ExcelDna.Testing/ExcelDna.Testing/Remote/PlainMethodInfo.cs b/ExcelDna.Testing/ExcelDna.Testing/Remote/PlainMethodInfo.cs index e0d9903..7ca2f3e 100644 --- a/ExcelDna.Testing/ExcelDna.Testing/Remote/PlainMethodInfo.cs +++ b/ExcelDna.Testing/ExcelDna.Testing/Remote/PlainMethodInfo.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using Xunit.Abstractions; namespace ExcelDna.Testing.Remote { diff --git a/ExcelDna.Testing/ExcelDna.Testing/Remote/PlainTestFailed.cs b/ExcelDna.Testing/ExcelDna.Testing/Remote/PlainTestFailed.cs index efd629d..c5a1c86 100644 --- a/ExcelDna.Testing/ExcelDna.Testing/Remote/PlainTestFailed.cs +++ b/ExcelDna.Testing/ExcelDna.Testing/Remote/PlainTestFailed.cs @@ -1,4 +1,4 @@ -using Xunit.Abstractions; +using Xunit.Sdk; namespace ExcelDna.Testing.Remote { diff --git a/ExcelDna.Testing/ExcelDna.Testing/Remote/RemoteExcel.cs b/ExcelDna.Testing/ExcelDna.Testing/Remote/RemoteExcel.cs index 785132a..c59161c 100644 --- a/ExcelDna.Testing/ExcelDna.Testing/Remote/RemoteExcel.cs +++ b/ExcelDna.Testing/ExcelDna.Testing/Remote/RemoteExcel.cs @@ -44,7 +44,7 @@ public async Task CloseHostAsync() } #pragma warning restore CS1998 - private bool SendBusMessage(Xunit.Abstractions.IMessageSinkMessage message) + private bool SendBusMessage(IMessageSinkMessage message) { if (BusMessage == null) return false; diff --git a/ExcelDna.Testing/ExcelDna.Testing/Remote/TestFrameworkOptions.cs b/ExcelDna.Testing/ExcelDna.Testing/Remote/TestFrameworkOptions.cs index abdb801..f9a5791 100644 --- a/ExcelDna.Testing/ExcelDna.Testing/Remote/TestFrameworkOptions.cs +++ b/ExcelDna.Testing/ExcelDna.Testing/Remote/TestFrameworkOptions.cs @@ -1,5 +1,5 @@ using System.Collections.Generic; -using Xunit.Abstractions; +using Xunit.Sdk; namespace ExcelDna.Testing.Remote { diff --git a/ExcelDna.Testing/ExcelDna.Testing/RemoteTestAssemblyRunner.cs b/ExcelDna.Testing/ExcelDna.Testing/RemoteTestAssemblyRunner.cs index 29c6803..1a83586 100644 --- a/ExcelDna.Testing/ExcelDna.Testing/RemoteTestAssemblyRunner.cs +++ b/ExcelDna.Testing/ExcelDna.Testing/RemoteTestAssemblyRunner.cs @@ -4,9 +4,8 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; -using Xunit; -using Xunit.Abstractions; using Xunit.Sdk; +using Xunit.v3; namespace ExcelDna.Testing { diff --git a/ExcelDna.Testing/ExcelDna.Testing/RunnerUtil.cs b/ExcelDna.Testing/ExcelDna.Testing/RunnerUtil.cs index cdc39c7..c87e834 100644 --- a/ExcelDna.Testing/ExcelDna.Testing/RunnerUtil.cs +++ b/ExcelDna.Testing/ExcelDna.Testing/RunnerUtil.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using Xunit.Abstractions; +using Xunit.Sdk; namespace ExcelDna.Testing {