diff --git a/.github/workflows/NUnit3TestAdapter.Cake.CI.yml b/.github/workflows/NUnit3TestAdapter.Cake.CI.yml index c6b17798..3749c951 100644 --- a/.github/workflows/NUnit3TestAdapter.Cake.CI.yml +++ b/.github/workflows/NUnit3TestAdapter.Cake.CI.yml @@ -12,9 +12,10 @@ jobs: - uses: actions/setup-dotnet@v2 with: dotnet-version: | - 2.1.x 3.1.x 5.0.x + 6.0.x + 7.0.x - name: Build with cake run: .\build.ps1 -t CI shell: pwsh diff --git a/.github/workflows/sonarbuild.yml b/.github/workflows/sonarbuild.yml.UnderWork similarity index 100% rename from .github/workflows/sonarbuild.yml rename to .github/workflows/sonarbuild.yml.UnderWork diff --git a/LICENSE b/LICENSE index 3302bf8b..6783f2bb 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2011-2020 Charlie Poole, 2014-2022 Terje Sandstrom +Copyright (c) 2011-2020 Charlie Poole, 2014-2023 Terje Sandstrom Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/NUnit3TestAdapter.sln b/NUnit3TestAdapter.sln index b6964428..8dcaba4d 100644 --- a/NUnit3TestAdapter.sln +++ b/NUnit3TestAdapter.sln @@ -38,14 +38,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NUnit.TestAdapter.Tests", " EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NUnit3AdapterExternalTests", "src\NUnit3AdapterExternalTests\NUnit3AdapterExternalTests.csproj", "{A4EA819A-D77D-46D3-B2B7-2C754DBD2BC7}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "net35", "net35", "{D41249E3-C080-4B66-8CBD-99CE4D309A10}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "net462", "net462", "{D41249E3-C080-4B66-8CBD-99CE4D309A10}" ProjectSection(SolutionItems) = preProject - nuget\net35\NUnit3TestAdapter.props = nuget\net35\NUnit3TestAdapter.props - EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "netcoreapp2.1", "netcoreapp2.1", "{A9584E41-6ECE-44B4-A504-41795A65DA5F}" - ProjectSection(SolutionItems) = preProject - nuget\netcoreapp2.1\NUnit3TestAdapter.props = nuget\netcoreapp2.1\NUnit3TestAdapter.props + nuget\net462\NUnit3TestAdapter.props = nuget\net462\NUnit3TestAdapter.props EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NUnit.TestAdapter.Tests.Acceptance", "src\NUnit.TestAdapter.Tests.Acceptance\NUnit.TestAdapter.Tests.Acceptance.csproj", "{3FAC7EE0-664F-4B11-918B-8E0FF865EE4C}" @@ -54,6 +49,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "github", "github", "{062B17 ProjectSection(SolutionItems) = preProject .github\dependabot.yml = .github\dependabot.yml .github\ISSUE_TEMPLATE.md = .github\ISSUE_TEMPLATE.md + .github\workflows\sonarbuild.yml.UnderWork = .github\workflows\sonarbuild.yml.UnderWork EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{7D708804-B2F1-4A31-A9FB-85A0C7433200}" @@ -102,7 +98,6 @@ Global EndGlobalSection GlobalSection(NestedProjects) = preSolution {D41249E3-C080-4B66-8CBD-99CE4D309A10} = {DE347D88-F6ED-4031-AFC2-318F63E39BC9} - {A9584E41-6ECE-44B4-A504-41795A65DA5F} = {DE347D88-F6ED-4031-AFC2-318F63E39BC9} {062B1763-73C8-4B5A-92DF-C66A36C43CE1} = {7CE30108-5D81-4850-BE6B-C8BCA35D3592} {7D708804-B2F1-4A31-A9FB-85A0C7433200} = {062B1763-73C8-4B5A-92DF-C66A36C43CE1} {2F940513-5B8F-45A5-A188-7C5D03D1B50D} = {DE347D88-F6ED-4031-AFC2-318F63E39BC9} diff --git a/appveyor.yml b/appveyor.yml index d908f12d..dbe8b3ad 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,5 +1,5 @@ version: 3.11.{build} -image: Visual Studio 2019 +image: Visual Studio 2022 build_script: - ps: .\build.ps1 -Target "Appveyor" @@ -9,7 +9,6 @@ test: off artifacts: - path: package\*.nupkg -- path: package\*.vsix - path: package\*.zip deploy: diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 6c90587b..be73dc4c 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -9,10 +9,23 @@ jobs: vmImage: 'windows-latest' steps: - task: UseDotNet@2 - displayName: Install .NET Core 2.1 runtime + displayName: Install .NET Core 5.0 runtime + inputs: + packageType: runtime + version: 5.x + - task: UseDotNet@2 + displayName: Install .NET Core 6.0 sdk + inputs: + version: 6.x + - task: UseDotNet@2 + displayName: Install .NET Core 7.0 sdk + inputs: + version: 7.x + - task: UseDotNet@2 + displayName: Install .NET Core 3.1 runtime inputs: packageType: runtime - version: 2.1.x + version: 3.1.x - powershell: .\build.ps1 --target=CI --configuration=$(BuildConfiguration) displayName: Build, package, and test @@ -25,7 +38,12 @@ jobs: displayName: Install .NET Core 6.0 sdk inputs: version: 6.x - + + - task: UseDotNet@2 + displayName: Install .NET Core 7.0 sdk + inputs: + version: 7.x + - task: UseDotNet@2 displayName: Install .NET Core 5.0 runtime inputs: @@ -38,11 +56,5 @@ jobs: packageType: runtime version: 3.1.x - - task: UseDotNet@2 - displayName: Install .NET Core 2.1 runtime - inputs: - packageType: runtime - version: 2.1.x - - powershell: .\build.ps1 --target=Acceptance --configuration=$(BuildConfiguration) displayName: Build and test diff --git a/build.cake b/build.cake index 78dd09df..46d41f91 100644 --- a/build.cake +++ b/build.cake @@ -1,5 +1,5 @@ -#tool vswhere&version=2.8.4 -#tool Microsoft.TestPlatform&version=17.0.0 +#tool vswhere&version=3.1.1 +#tool Microsoft.TestPlatform&version=17.4.0 ////////////////////////////////////////////////////////////////////// // ARGUMENTS @@ -12,8 +12,8 @@ var configuration = Argument("configuration", "Release"); // SET PACKAGE VERSION ////////////////////////////////////////////////////////////////////// -var version = "4.3.1"; -var modifier = ""; +var version = "4.4.0"; +var modifier = "-beta.1"; var dbgSuffix = configuration.ToLower() == "debug" ? "-dbg" : ""; @@ -74,7 +74,7 @@ var ADAPTER_PROJECT = SRC_DIR + "NUnitTestAdapter/NUnit.TestAdapter.csproj"; var NETCOREAPP_TFM = "netcoreapp3.1"; -var ADAPTER_BIN_DIR_NET35 = SRC_DIR + $"NUnitTestAdapter/bin/{configuration}/net35/"; +var ADAPTER_BIN_DIR_NET462 = SRC_DIR + $"NUnitTestAdapter/bin/{configuration}/net462/"; var ADAPTER_BIN_DIR_NETCOREAPP = SRC_DIR + $"NUnitTestAdapter/bin/{configuration}/{NETCOREAPP_TFM}/"; var BIN_DIRS = new [] { @@ -171,7 +171,7 @@ string GetTestAssemblyPath(string framework) } foreach (var (framework, vstestFramework, adapterDir) in new[] { - ("net46", "Framework45", ADAPTER_BIN_DIR_NET35), + ("net462", "Framework45", ADAPTER_BIN_DIR_NET462), (NETCOREAPP_TFM, NETCOREAPP_TFM, ADAPTER_BIN_DIR_NETCOREAPP) }) { @@ -247,20 +247,20 @@ Task("CreateWorkingImage") CopyFileToDirectory("LICENSE", PACKAGE_IMAGE_DIR); // dotnet publish doesn't work for .NET 3.5 - var net35Files = new FilePath[] + var net462Files = new FilePath[] { - ADAPTER_BIN_DIR_NET35 + "NUnit3.TestAdapter.dll", - ADAPTER_BIN_DIR_NET35 + "NUnit3.TestAdapter.pdb", - ADAPTER_BIN_DIR_NET35 + "nunit.engine.dll", - ADAPTER_BIN_DIR_NET35 + "nunit.engine.api.dll", - ADAPTER_BIN_DIR_NET35 + "nunit.engine.core.dll", - ADAPTER_BIN_DIR_NET35 + "testcentric.engine.metadata.dll" + ADAPTER_BIN_DIR_NET462 + "NUnit3.TestAdapter.dll", + ADAPTER_BIN_DIR_NET462 + "NUnit3.TestAdapter.pdb", + ADAPTER_BIN_DIR_NET462 + "nunit.engine.dll", + ADAPTER_BIN_DIR_NET462 + "nunit.engine.api.dll", + ADAPTER_BIN_DIR_NET462 + "nunit.engine.core.dll", + ADAPTER_BIN_DIR_NET462 + "testcentric.engine.metadata.dll" }; - var net35Dir = PACKAGE_IMAGE_DIR + "build/net35"; - CreateDirectory(net35Dir); - CopyFiles(net35Files, net35Dir); - CopyFileToDirectory("nuget/net35/NUnit3TestAdapter.props", net35Dir); + var net462Dir = PACKAGE_IMAGE_DIR + "build/net462"; + CreateDirectory(net462Dir); + CopyFiles(net462Files, net462Dir); + CopyFileToDirectory("nuget/net462/NUnit3TestAdapter.props", net462Dir); var netcoreDir = PACKAGE_IMAGE_DIR + "build/" + NETCOREAPP_TFM; DotNetCorePublish(ADAPTER_PROJECT, new DotNetCorePublishSettings @@ -300,9 +300,9 @@ Task("Rebuild") .IsDependentOn("Build"); Task("Test") - .IsDependentOn("VSTest-net46") + .IsDependentOn("VSTest-net462") .IsDependentOn("VSTest-" + NETCOREAPP_TFM) - .IsDependentOn("DotnetTest-net46") + .IsDependentOn("DotnetTest-net462") .IsDependentOn("DotnetTest-" + NETCOREAPP_TFM); Task("Package") @@ -327,7 +327,9 @@ Task("Acceptance") .Description("Ensures that known project configurations can use the produced NuGet package to restore, build, and run tests.") .Does(() => { - var testAssembly = SRC_DIR + $"NUnit.TestAdapter.Tests.Acceptance/bin/{configuration}/net472/NUnit.VisualStudio.TestAdapter.Tests.Acceptance.dll"; + // Target framework specified here should be exactly the same as the one in the acceptance project file. + var targetframework = "net48"; + var testAssembly = SRC_DIR + $"NUnit.TestAdapter.Tests.Acceptance/bin/{configuration}/{targetframework}/NUnit.VisualStudio.TestAdapter.Tests.Acceptance.dll"; var keepWorkspaces = Argument("keep-workspaces", false) ?? true; diff --git a/nuget.config b/nuget.config index 9d42dd29..44d04257 100644 --- a/nuget.config +++ b/nuget.config @@ -1,8 +1,9 @@ - + - + + \ No newline at end of file diff --git a/nuget/NUnit3TestAdapter.nuspec b/nuget/NUnit3TestAdapter.nuspec index a04a6e3f..137d066f 100644 --- a/nuget/NUnit3TestAdapter.nuspec +++ b/nuget/NUnit3TestAdapter.nuspec @@ -18,20 +18,20 @@ For VS 2017 and forward, you should add this package to every test project in your solution. (Earlier versions only require a single adapter package per solution.) See https://docs.nunit.org/articles/vs-test-adapter/Adapter-Release-Notes.html - Copyright (c) 2011-2021 Charlie Poole, 2014-2022 Terje Sandstrom + Copyright (c) 2011-2021 Charlie Poole, 2014-2023 Terje Sandstrom en-US test visualstudio testadapter nunit nunit3 dotnet false - - - - - - - + + + + + + + @@ -40,5 +40,7 @@ + + diff --git a/nuget/net35/NUnit3TestAdapter.props b/nuget/net462/NUnit3TestAdapter.props similarity index 100% rename from nuget/net35/NUnit3TestAdapter.props rename to nuget/net462/NUnit3TestAdapter.props diff --git a/nuget/netcoreapp2.1/NUnit3TestAdapter.props b/nuget/netcoreapp2.1/NUnit3TestAdapter.props deleted file mode 100644 index 5e45aede..00000000 --- a/nuget/netcoreapp2.1/NUnit3TestAdapter.props +++ /dev/null @@ -1,35 +0,0 @@ - - - - - NUnit3.TestAdapter.dll - PreserveNewest - False - - - NUnit3.TestAdapter.pdb - PreserveNewest - False - - - nunit.engine.dll - PreserveNewest - False - - - nunit.engine.api.dll - PreserveNewest - False - - - nunit.engine.core.dll - PreserveNewest - False - - - testcentric.engine.metadata.dll - PreserveNewest - False - - - diff --git a/nuget/netcoreapp3.1/NUnit3TestAdapter.props b/nuget/netcoreapp3.1/NUnit3TestAdapter.props index 5e45aede..b812e855 100644 --- a/nuget/netcoreapp3.1/NUnit3TestAdapter.props +++ b/nuget/netcoreapp3.1/NUnit3TestAdapter.props @@ -31,5 +31,10 @@ PreserveNewest False + + Microsoft.Extensions.DependencyModel.dll + PreserveNewest + False + diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 679a169a..d6b2ea42 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -13,8 +13,7 @@ - - + diff --git a/src/NUnit.TestAdapter.Tests.Acceptance/AcceptanceTests.cs b/src/NUnit.TestAdapter.Tests.Acceptance/AcceptanceTests.cs index acafe068..c97cd959 100644 --- a/src/NUnit.TestAdapter.Tests.Acceptance/AcceptanceTests.cs +++ b/src/NUnit.TestAdapter.Tests.Acceptance/AcceptanceTests.cs @@ -13,7 +13,6 @@ namespace NUnit.VisualStudio.TestAdapter.Tests.Acceptance public class Frameworks { public const string NetCoreApp31 = "netcoreapp3.1"; - public const string NetCoreApp21 = "netcoreapp2.1"; public const string Net50 = "net5.0"; public const string Net60 = "net6.0"; public const string Net70 = "net7.0"; @@ -26,8 +25,8 @@ public abstract class AcceptanceTests public static string NuGetPackageVersion => Initialization.Value.NupkgVersion; - public const string LowestNetfxTarget = "net35"; - public const string LegacyProjectTargetFrameworkVersion = "v3.5"; + public const string LowestNetfxTarget = "net462"; + public const string LegacyProjectTargetFrameworkVersion = "v4.6.2"; public static IEnumerable TargetFrameworks => new[] { @@ -37,7 +36,6 @@ public abstract class AcceptanceTests public static IEnumerable DotNetCliTargetFrameworks => new[] { - // Frameworks.NetCoreApp21, // Doesnt seem to be supported by VS 2022 anymore Frameworks.NetCoreApp31, Frameworks.Net50, Frameworks.Net60, diff --git a/src/NUnit.TestAdapter.Tests.Acceptance/NUnit.TestAdapter.Tests.Acceptance.csproj b/src/NUnit.TestAdapter.Tests.Acceptance/NUnit.TestAdapter.Tests.Acceptance.csproj index d7ef4b34..ef252a1c 100644 --- a/src/NUnit.TestAdapter.Tests.Acceptance/NUnit.TestAdapter.Tests.Acceptance.csproj +++ b/src/NUnit.TestAdapter.Tests.Acceptance/NUnit.TestAdapter.Tests.Acceptance.csproj @@ -11,7 +11,7 @@ - + diff --git a/src/NUnit.TestAdapter.Tests.Acceptance/SinglePassingTestResultTests.cs b/src/NUnit.TestAdapter.Tests.Acceptance/SinglePassingTestResultTests.cs index 01d72b2b..e2325deb 100644 --- a/src/NUnit.TestAdapter.Tests.Acceptance/SinglePassingTestResultTests.cs +++ b/src/NUnit.TestAdapter.Tests.Acceptance/SinglePassingTestResultTests.cs @@ -419,10 +419,10 @@ private static void AddPackagesConfig(IsolatedWorkspace workspace) workspace.AddFile("packages.config", $@" - - - - + + + + "); } @@ -446,7 +446,7 @@ public static void Legacy_csproj_with_packages_config() Properties Test Test - v4.5 + v4.6.2 512 true @@ -537,7 +537,7 @@ public static void Legacy_vbproj_with_packages_config() Test 512 Windows - v4.5 + v4.6.2 true diff --git a/src/NUnitTestAdapter/EmbeddedAssemblyResolution.cs b/src/NUnitTestAdapter/EmbeddedAssemblyResolution.cs index 654cf8fa..073fbd6c 100644 --- a/src/NUnitTestAdapter/EmbeddedAssemblyResolution.cs +++ b/src/NUnitTestAdapter/EmbeddedAssemblyResolution.cs @@ -28,7 +28,7 @@ using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; -#if !NET35 +#if !NET462 using System.Runtime.Loader; #endif @@ -39,14 +39,14 @@ internal static class EmbeddedAssemblyResolution [ModuleInitializer] public static void EnsureInitialized() { -#if NET35 +#if NET462 AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve; #else AssemblyLoadContext.Default.Resolving += Default_Resolving; #endif } -#if NET35 +#if NET462 private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) { using (var stream = TryGetResourceAssemblyStream(new AssemblyName(args.Name))) @@ -78,13 +78,13 @@ private static Stream TryGetResourceAssemblyStream(AssemblyName assemblyName) if (properCasing == null) return null; return typeof(EmbeddedAssemblyResolution) -#if !NET35 +#if !NET462 .GetTypeInfo() #endif .Assembly.GetManifestResourceStream(@"Assemblies/" + properCasing + ".dll"); } -#if NET35 +#if NET462 private static byte[] ReadToEnd(this Stream stream) { if (stream == null) throw new ArgumentNullException(nameof(stream)); diff --git a/src/NUnitTestAdapter/Internal/Extensions.cs b/src/NUnitTestAdapter/Internal/Extensions.cs index 73e9f534..a0f8fb2a 100644 --- a/src/NUnitTestAdapter/Internal/Extensions.cs +++ b/src/NUnitTestAdapter/Internal/Extensions.cs @@ -2,7 +2,7 @@ namespace NUnit.VisualStudio.TestAdapter.Internal { -#if NET35 +#if NET462DISABLED public static class TypeExtensions { public static Type GetTypeInfo(this Type type) => type; diff --git a/src/NUnitTestAdapter/Metadata/AppDomainMetadataProvider.cs b/src/NUnitTestAdapter/Metadata/AppDomainMetadataProvider.cs index 2a10bad6..df85c391 100644 --- a/src/NUnitTestAdapter/Metadata/AppDomainMetadataProvider.cs +++ b/src/NUnitTestAdapter/Metadata/AppDomainMetadataProvider.cs @@ -21,7 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** -#if NET35 +#if NET462 using System; namespace NUnit.VisualStudio.TestAdapter.Metadata diff --git a/src/NUnitTestAdapter/Metadata/DirectReflectionMetadataProvider.cs b/src/NUnitTestAdapter/Metadata/DirectReflectionMetadataProvider.cs index 86db8aa9..196bb7bd 100644 --- a/src/NUnitTestAdapter/Metadata/DirectReflectionMetadataProvider.cs +++ b/src/NUnitTestAdapter/Metadata/DirectReflectionMetadataProvider.cs @@ -27,7 +27,7 @@ using System.Reflection; using NUnit.VisualStudio.TestAdapter.Internal; -#if !NET35 +#if !NET462 using System.Runtime.Loader; #endif @@ -40,11 +40,7 @@ internal sealed class DirectReflectionMetadataProvider : IMetadataProvider var type = TryGetSingleMethod(assemblyPath, reflectedTypeName, methodName)?.DeclaringType; if (type == null) return null; -#if NET35 - if (type.IsGenericType) -#else if (type.IsConstructedGenericType) -#endif { type = type.GetGenericTypeDefinition(); } @@ -88,7 +84,7 @@ private static MethodInfo TryGetSingleMethod(string assemblyPath, string reflect { try { -#if !NET35 +#if !NET462 var assembly = AssemblyLoadContext.Default.LoadFromAssemblyPath(assemblyPath); #else var assembly = Assembly.LoadFrom(assemblyPath); diff --git a/src/NUnitTestAdapter/Metadata/TypeInfo.cs b/src/NUnitTestAdapter/Metadata/TypeInfo.cs index 3e98f1ab..40e31217 100644 --- a/src/NUnitTestAdapter/Metadata/TypeInfo.cs +++ b/src/NUnitTestAdapter/Metadata/TypeInfo.cs @@ -27,7 +27,7 @@ namespace NUnit.VisualStudio.TestAdapter.Metadata { -#if NET35 +#if NET462 [Serializable] #endif public struct TypeInfo diff --git a/src/NUnitTestAdapter/NUnit.TestAdapter.csproj b/src/NUnitTestAdapter/NUnit.TestAdapter.csproj index 3bd554b4..6cd5423d 100644 --- a/src/NUnitTestAdapter/NUnit.TestAdapter.csproj +++ b/src/NUnitTestAdapter/NUnit.TestAdapter.csproj @@ -6,7 +6,7 @@ NUnit.VisualStudio.TestAdapter - net35;netcoreapp3.1 + net462;netcoreapp3.1 false https://github.com/nunit/nunit3-vs-adapter true @@ -17,23 +17,24 @@ Charlie Poole, Terje Sandstrom - + false - + - + + @@ -53,12 +54,4 @@ - - - diff --git a/src/NUnitTestAdapter/NUnit3TestDiscoverer.cs b/src/NUnitTestAdapter/NUnit3TestDiscoverer.cs index adc7a26b..e41d4094 100644 --- a/src/NUnitTestAdapter/NUnit3TestDiscoverer.cs +++ b/src/NUnitTestAdapter/NUnit3TestDiscoverer.cs @@ -39,7 +39,7 @@ namespace NUnit.VisualStudio.TestAdapter { -#if !NET35 +#if !NET462 [FileExtension(".appx")] #endif [FileExtension(".dll")] diff --git a/src/NUnitTestAdapter/NUnitEngine/NUnitEngineAdapter.cs b/src/NUnitTestAdapter/NUnitEngine/NUnitEngineAdapter.cs index cc4aaeda..553876e3 100644 --- a/src/NUnitTestAdapter/NUnitEngine/NUnitEngineAdapter.cs +++ b/src/NUnitTestAdapter/NUnitEngine/NUnitEngineAdapter.cs @@ -58,11 +58,14 @@ public class NUnitEngineAdapter : INUnitEngineAdapter, IDisposable public void Initialize() { -#if NET35 +#if NET462 var engineX = new TestEngine(); #else var engineX = TestEngineActivator.CreateInstance(); #endif + if (engineX == null) + engineX = new TestEngine(); + InternalEngineCreated?.Invoke(engineX); TestEngine = engineX; var tmpPath = Path.Combine(Path.GetTempPath(), "NUnit.Engine"); diff --git a/src/NUnitTestAdapter/NUnitEventListener.cs b/src/NUnitTestAdapter/NUnitEventListener.cs index 1d66ef2c..430b2c87 100644 --- a/src/NUnitTestAdapter/NUnitEventListener.cs +++ b/src/NUnitTestAdapter/NUnitEventListener.cs @@ -23,12 +23,13 @@ using System; using System.Collections.Generic; -#if NET35 +#if NET462 using System.Runtime.Remoting; #endif using Microsoft.VisualStudio.TestPlatform.ObjectModel; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; + using NUnit.Engine; using NUnit.VisualStudio.TestAdapter; using NUnit.VisualStudio.TestAdapter.Dump; @@ -42,7 +43,7 @@ namespace NUnit.VisualStudio.TestAdapter /// translates each event into a message for the VS test platform. /// public class NUnitEventListener : -#if NET35 +#if NET462 MarshalByRefObject, #endif ITestEventListener, IDisposable // Public for testing @@ -51,9 +52,9 @@ public class NUnitEventListener : private readonly ITestExecutionRecorder recorder; private readonly ITestConverterCommon testConverter; private readonly IAdapterSettings settings; - private readonly Dictionary> outputNodes = new (); + private readonly Dictionary> outputNodes = new(); -#if NET35 +#if NET462 public override object InitializeLifetimeService() { // Give the listener an infinite lease lifetime by returning null @@ -126,7 +127,7 @@ protected virtual void Dispose(bool disposing) { if (disposing) { -#if NET35 +#if NET462 RemotingServices.Disconnect(this); #endif } diff --git a/src/NUnitTestAdapter/NUnitTestAdapter.cs b/src/NUnitTestAdapter/NUnitTestAdapter.cs index 3989116a..ccea2855 100644 --- a/src/NUnitTestAdapter/NUnitTestAdapter.cs +++ b/src/NUnitTestAdapter/NUnitTestAdapter.cs @@ -26,7 +26,7 @@ using System.Diagnostics; using System.IO; using System.Reflection; -#if NET35 +#if NET462 using System.Runtime.Remoting.Channels; #endif using System.Linq; @@ -62,7 +62,7 @@ public abstract class NUnitTestAdapter protected NUnitTestAdapter() { -#if !NET35 +#if !NET462 AdapterVersion = typeof(NUnitTestAdapter).GetTypeInfo().Assembly.GetName().Version.ToString(); #else AdapterVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString(); @@ -313,7 +313,7 @@ private static void SetTestParameters( /// protected static void CleanUpRegisteredChannels() { -#if NET35 +#if NET462 foreach (var chan in ChannelServices.RegisteredChannels) ChannelServices.UnregisterChannel(chan); #endif diff --git a/src/NUnitTestAdapter/NavigationDataProvider.cs b/src/NUnitTestAdapter/NavigationDataProvider.cs index afe5ad9f..284969c1 100644 --- a/src/NUnitTestAdapter/NavigationDataProvider.cs +++ b/src/NUnitTestAdapter/NavigationDataProvider.cs @@ -38,7 +38,7 @@ public sealed class NavigationDataProvider : IDisposable private bool _disableMetadataLookup; public NavigationDataProvider(string assemblyPath, ITestLogger logger) -#if !NET35 +#if !NET462 : this(assemblyPath, logger, new DirectReflectionMetadataProvider()) #else : this(assemblyPath, logger, CreateMetadataProvider(assemblyPath)) @@ -46,7 +46,7 @@ public NavigationDataProvider(string assemblyPath, ITestLogger logger) { } -#if NET35 +#if NET462 internal static AppDomainMetadataProvider CreateMetadataProvider(string assemblyPath) { return new ( diff --git a/src/NUnitTestAdapter/Properties/AssemblyInfo.cs b/src/NUnitTestAdapter/Properties/AssemblyInfo.cs index 3c0dadce..528247a1 100644 --- a/src/NUnitTestAdapter/Properties/AssemblyInfo.cs +++ b/src/NUnitTestAdapter/Properties/AssemblyInfo.cs @@ -1,5 +1,5 @@ // **************************************************************** -// Copyright (c) 2011-2021 Charlie Poole, 2014-2022 Terje Sandstrom. +// Copyright (c) 2011-2021 Charlie Poole, 2014-2023 Terje Sandstrom. // **************************************************************** using System; @@ -12,7 +12,7 @@ [assembly: AssemblyDescription("A package containing the NUnit3 TestAdapter for Visual Studio 2012 onwards. \n\r\nThe package works with Visual Studio 2012 and newer, dotnet test and VSTest.Console.\r\n")] [assembly: AssemblyCompany("NUnit Project")] [assembly: AssemblyProduct("NUnit3TestAdapter")] -[assembly: AssemblyCopyright("Copyright © 2011-2021 Charlie Poole, 2014-2022 Terje Sandstrom")] +[assembly: AssemblyCopyright("Copyright © 2011-2021 Charlie Poole, 2014-2023 Terje Sandstrom")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] [assembly: CLSCompliant(false)] @@ -21,7 +21,7 @@ [assembly: ComVisible(false)] [assembly: Guid("c0aad5e4-b486-49bc-b3e8-31e01be6fefe")] -[assembly: AssemblyVersion("4.3.1.0")] -[assembly: AssemblyFileVersion("4.3.1.0")] +[assembly: AssemblyVersion("4.4.0.0")] +[assembly: AssemblyFileVersion("4.4.0.0")] [assembly: InternalsVisibleTo("NUnit.VisualStudio.TestAdapter.Tests, PublicKey=002400000480000094000000060200000024000052534131000400000100010029b97dea816272cc4ea44cf3cf666f8150d6dfe1274b6c2e6c4d54259b756888ec08ad6dd3ea0f540b30408b948ae5f39cf0c7b210abdec267b367ce1eccab97d5c6c02ee67090827ffd699544fa2add4849b45a1901eac08495bfee0397fba3946ff3912ce0b9a497818e418a77a0c8db4ca1780e7b6f6dd6911395fcc0faba")] diff --git a/src/NUnitTestAdapter/TestLogger.cs b/src/NUnitTestAdapter/TestLogger.cs index 0316bbb0..79fd3915 100644 --- a/src/NUnitTestAdapter/TestLogger.cs +++ b/src/NUnitTestAdapter/TestLogger.cs @@ -151,10 +151,10 @@ public void SendMessage(TestMessageLevel testMessageLevel, string message, Excep #region SpecializedMessages public void DebugRunfrom() { -#if NET35 - string fw = "Net Framework"; +#if NET462 + string fw = ".Net Framework"; #else - string fw = "Net Core"; + string fw = ".Net/ .Net Core"; #endif var assLoc = Assembly.GetExecutingAssembly().Location; Debug($"{fw} adapter running from {assLoc}"); diff --git a/src/NUnitTestAdapterTests/AppDomainInvoker.cs b/src/NUnitTestAdapterTests/AppDomainInvoker.cs index f45831bb..9eeb44f8 100644 --- a/src/NUnitTestAdapterTests/AppDomainInvoker.cs +++ b/src/NUnitTestAdapterTests/AppDomainInvoker.cs @@ -21,7 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** -#if NET46 +#if NET462 using System; using System.IO; using System.Reflection; diff --git a/src/NUnitTestAdapterTests/NUnit.TestAdapter.Tests.csproj b/src/NUnitTestAdapterTests/NUnit.TestAdapter.Tests.csproj index 28b457e2..37f17fe1 100644 --- a/src/NUnitTestAdapterTests/NUnit.TestAdapter.Tests.csproj +++ b/src/NUnitTestAdapterTests/NUnit.TestAdapter.Tests.csproj @@ -4,8 +4,8 @@ true NUnit.VisualStudio.TestAdapter.Tests NUnit.VisualStudio.TestAdapter.Tests - net46;netcoreapp3.1 - + net462;netcoreapp3.1 + true true @@ -19,13 +19,14 @@ - + + - - + + diff --git a/src/NUnitTestAdapterTests/NUnit3TestDiscovererTests.cs b/src/NUnitTestAdapterTests/NUnit3TestDiscovererTests.cs index 74c04180..04459bbc 100644 --- a/src/NUnitTestAdapterTests/NUnit3TestDiscovererTests.cs +++ b/src/NUnitTestAdapterTests/NUnit3TestDiscovererTests.cs @@ -23,6 +23,11 @@ using System.Collections.Generic; using System.Reflection; + +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; + +using NSubstitute; + using NUnit.Framework; namespace NUnit.VisualStudio.TestAdapter.Tests @@ -43,7 +48,8 @@ public void ThatDiscovererNUnitEngineAdapterIsInitialized() { var sut = new NUnit3TestDiscoverer(); Assert.That(sut.NUnitEngineAdapter, Is.Not.Null); - sut.DiscoverTests(new List(), null, null, null); + var dc = Substitute.For(); + sut.DiscoverTests(new List(), dc, null, null); Assert.That(sut.NUnitEngineAdapter, Is.Not.Null); } } diff --git a/src/NUnitTestAdapterTests/NUnitEventListenerTests.cs b/src/NUnitTestAdapterTests/NUnitEventListenerTests.cs index 2a4e531a..19aa58ea 100644 --- a/src/NUnitTestAdapterTests/NUnitEventListenerTests.cs +++ b/src/NUnitTestAdapterTests/NUnitEventListenerTests.cs @@ -23,14 +23,17 @@ using System; using System.Collections.Generic; -#if NET35 +#if NET462 using System.Runtime.Remoting; #endif using System.Xml; + using Microsoft.VisualStudio.TestPlatform.ObjectModel; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; + using NSubstitute; + using NUnit.Framework; using NUnit.VisualStudio.TestAdapter.Dump; using NUnit.VisualStudio.TestAdapter.NUnitEngine; @@ -73,7 +76,7 @@ public void SetUp() public void TestStarted_CallsRecordStartCorrectly() { listener.OnTestEvent(""); - Assert.That(testLog.Events.Count, Is.EqualTo(1)); + Assert.That(testLog.Events, Has.Count.EqualTo(1)); Assert.That( testLog.Events[0].EventType, Is.EqualTo(FakeFrameworkHandle.EventType.RecordStart)); @@ -89,10 +92,13 @@ public void TestStarted_CallsRecordStartCorrectly() public void TestFinished_CallsRecordEnd_Then_RecordResult() { listener.TestFinished(new NUnitTestEventTestCase(FakeTestData.GetResultNode().AsString())); - Assert.That(testLog.Events.Count, Is.EqualTo(2)); - Assert.That(testLog.Events[0].EventType, Is.EqualTo(FakeFrameworkHandle.EventType.RecordEnd)); - Assert.That( - testLog.Events[1].EventType, Is.EqualTo(FakeFrameworkHandle.EventType.RecordResult)); + Assert.That(testLog.Events, Has.Count.EqualTo(2)); + Assert.Multiple(() => + { + Assert.That(testLog.Events[0].EventType, Is.EqualTo(FakeFrameworkHandle.EventType.RecordEnd)); + Assert.That( + testLog.Events[1].EventType, Is.EqualTo(FakeFrameworkHandle.EventType.RecordResult)); + }); } [Test] @@ -124,7 +130,7 @@ public void TestFinished_DoNotSendWhiteSpaceToMessages(string data) testcase.Output.Returns($"{data}"); settings.ConsoleOut.Returns(1); listener.TestFinished(testcase); - Assert.That(testLog.Events.Count, Is.EqualTo(0)); + Assert.That(testLog.Events, Is.Empty); } @@ -187,24 +193,24 @@ public void TestOutput_SendsMessageWithCorrectMessageLevel(NUnitTestEventTestOut #endregion #region Listener Lifetime Tests -#if NET35 +#if NET462 [Test] public void Listener_LeaseLifetimeWillNotExpire() { testLog = new FakeFrameworkHandle(); - var settings = Substitute.For(); - settings.CollectSourceInformation.Returns(true); - using (var testConverter = new TestConverter(new TestLogger(new MessageLoggerStub()), FakeTestData.AssemblyPath, settings)) - { - var localInstance = (MarshalByRefObject)Activator.CreateInstance(typeof(NUnitEventListener), testLog, testConverter, null); + var adapterSettings = Substitute.For(); + adapterSettings.CollectSourceInformation.Returns(true); + var discoveryConverter = Substitute.For(); + using var testConverter = new TestConverter(new TestLogger(new MessageLoggerStub()), FakeTestData.AssemblyPath, adapterSettings, discoveryConverter); + var executor = Substitute.For(); + var localInstance = (MarshalByRefObject)Activator.CreateInstance(typeof(NUnitEventListener), testConverter, executor); - RemotingServices.Marshal(localInstance); + RemotingServices.Marshal(localInstance); - var lifetime = ((MarshalByRefObject)localInstance).GetLifetimeService(); + var lifetime = ((MarshalByRefObject)localInstance).GetLifetimeService(); - // A null lifetime (as opposed to an ILease) means the object has an infinite lifetime - Assert.IsNull(lifetime); - } + // A null lifetime (as opposed to an ILease) means the object has an infinite lifetime + Assert.That(lifetime, Is.Null); } #endif #endregion @@ -214,13 +220,19 @@ public void Listener_LeaseLifetimeWillNotExpire() private void VerifyTestCase(TestCase ourCase) { Assert.That(ourCase, Is.Not.Null, "TestCase not set"); - Assert.That(ourCase.DisplayName, Is.EqualTo(FakeTestData.DisplayName)); - Assert.That(ourCase.FullyQualifiedName, Is.EqualTo(FakeTestData.FullyQualifiedName)); - Assert.That(ourCase.Source, Is.EqualTo(FakeTestData.AssemblyPath)); + Assert.Multiple(() => + { + Assert.That(ourCase.DisplayName, Is.EqualTo(FakeTestData.DisplayName)); + Assert.That(ourCase.FullyQualifiedName, Is.EqualTo(FakeTestData.FullyQualifiedName)); + Assert.That(ourCase.Source, Is.EqualTo(FakeTestData.AssemblyPath)); + }); if (ourCase.CodeFilePath != null) // Unavailable if not running under VS { - Assert.That(ourCase.CodeFilePath, Is.SamePath(FakeTestData.CodeFile)); - Assert.That(ourCase.LineNumber, Is.EqualTo(FakeTestData.LineNumber)); + Assert.Multiple(() => + { + Assert.That(ourCase.CodeFilePath, Is.SamePath(FakeTestData.CodeFile)); + Assert.That(ourCase.LineNumber, Is.EqualTo(FakeTestData.LineNumber)); + }); } } @@ -228,11 +240,13 @@ private void VerifyTestResult(VSTestResult ourResult) { Assert.That(ourResult, Is.Not.Null, "TestResult not set"); VerifyTestCase(ourResult.TestCase); - - Assert.That(ourResult.ComputerName, Is.EqualTo(Environment.MachineName)); - Assert.That(ourResult.Outcome, Is.EqualTo(TestOutcome.Passed)); - Assert.That(ourResult.ErrorMessage, Is.EqualTo(null)); - Assert.That(ourResult.Duration, Is.EqualTo(TimeSpan.FromSeconds(1.234))); + Assert.Multiple(() => + { + Assert.That(ourResult.ComputerName, Is.EqualTo(Environment.MachineName)); + Assert.That(ourResult.Outcome, Is.EqualTo(TestOutcome.Passed)); + Assert.That(ourResult.ErrorMessage, Is.EqualTo(null)); + Assert.That(ourResult.Duration, Is.EqualTo(TimeSpan.FromSeconds(1.234))); + }); } #endregion diff --git a/src/NUnitTestAdapterTests/NavigationDataProviderTests.cs b/src/NUnitTestAdapterTests/NavigationDataProviderTests.cs index 8aad9d59..5a59ad15 100644 --- a/src/NUnitTestAdapterTests/NavigationDataProviderTests.cs +++ b/src/NUnitTestAdapterTests/NavigationDataProviderTests.cs @@ -35,7 +35,7 @@ namespace NUnit.VisualStudio.TestAdapter.Tests { public static class NavigationDataProviderTests { -#if NET46 +#if NET462 [Ignore("Joseph: This doesn't really work!")] [Description( "This simulates what happens when the adapter is deployed: " + diff --git a/src/NUnitTestAdapterTests/ProjectTests.cs b/src/NUnitTestAdapterTests/ProjectTests.cs index cd8816a4..ce136d3f 100644 --- a/src/NUnitTestAdapterTests/ProjectTests.cs +++ b/src/NUnitTestAdapterTests/ProjectTests.cs @@ -30,7 +30,7 @@ namespace NUnit.VisualStudio.TestAdapter.Tests [TestFixture] public class ProjectTests { -#if NET35 +#if NET462 [Test] public void ThatTheReferenceToMicrosoftTestObjectModelPointsToVS2012Version() { diff --git a/src/NUnitTestAdapterTests/TestAdapterUtils.cs b/src/NUnitTestAdapterTests/TestAdapterUtils.cs index fa15605c..99a51dc2 100644 --- a/src/NUnitTestAdapterTests/TestAdapterUtils.cs +++ b/src/NUnitTestAdapterTests/TestAdapterUtils.cs @@ -47,7 +47,7 @@ public static ITestExecutor CreateExecutor() private static void InitializeForTesting(NUnitTestAdapter adapter) { -#if NET46 +#if NET462 adapter.NUnitEngineAdapter.InternalEngineCreated += engine => { var concreteEngineType = (NUnit.Engine.TestEngine)engine; diff --git a/src/NUnitTestAdapterTests/TestDiscoveryTests.cs b/src/NUnitTestAdapterTests/TestDiscoveryTests.cs index 9db7312f..73e337d8 100644 --- a/src/NUnitTestAdapterTests/TestDiscoveryTests.cs +++ b/src/NUnitTestAdapterTests/TestDiscoveryTests.cs @@ -180,7 +180,7 @@ public void WhenAssemblyDontExist() }); } -#if NET46 +#if NET462 [Test] public void WhenAssemblyIsNative() { diff --git a/src/NUnitTestAdapterTests/TestExecutionTests.cs b/src/NUnitTestAdapterTests/TestExecutionTests.cs index c3a6b7c3..9a2fccc6 100644 --- a/src/NUnitTestAdapterTests/TestExecutionTests.cs +++ b/src/NUnitTestAdapterTests/TestExecutionTests.cs @@ -1,5 +1,5 @@ // *********************************************************************** -// Copyright (c) 2012-2021 Charlie Poole, Terje Sandstrom +// Copyright (c) 2012-2021 Charlie Poole, 2014-2023 Terje Sandstrom // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -252,7 +252,7 @@ public void AttachmentsShowSupportMultipleFiles() VerifyAttachment(attachmentSet.Attachments[1], FixtureWithAttachment.Attachment2Name, FixtureWithAttachment.Attachment2Description); } -#if NET46 +#if NET462 [Test] public void NativeAssemblyProducesWarning() { @@ -340,7 +340,7 @@ public void LoadMockAssembly() .ToList(); Summary = new ResultSummary(testResults); } -#if NET35 +#if NET462 [Test] public void ThatTestOutputXmlHasBeenCreatedBelowAssemblyFolder() { diff --git a/src/empty-assembly/empty-assembly.csproj b/src/empty-assembly/empty-assembly.csproj index 036c83e6..9bbe3109 100644 --- a/src/empty-assembly/empty-assembly.csproj +++ b/src/empty-assembly/empty-assembly.csproj @@ -4,7 +4,7 @@ false empty-assembly NUnit.Tests - net35;netcoreapp3.1 + net462;netcoreapp3.1 diff --git a/src/mock-assembly/mock-assembly.csproj b/src/mock-assembly/mock-assembly.csproj index 56dacffe..f46bc4d9 100644 --- a/src/mock-assembly/mock-assembly.csproj +++ b/src/mock-assembly/mock-assembly.csproj @@ -4,7 +4,7 @@ false mock-assembly NUnit.Tests - net35;netcoreapp3.1 + net462;netcoreapp3.1