From ea2ea94b627bb27990d99a9e3e106d2cb27804bd Mon Sep 17 00:00:00 2001 From: Terje Sandstrom Date: Sun, 19 Mar 2023 13:11:18 +0100 Subject: [PATCH] Added engine with fix for NUnit 4 (#1081) --- build.cake | 4 +- nuget.config | 2 +- src/NUnitTestAdapter/AdapterSettings.cs | 3 +- src/NUnitTestAdapter/NUnit.TestAdapter.csproj | 17 +++++-- .../{AssemblyInfo.cs => AssemblyInfoExtra.cs} | 14 +----- .../NUnit.TestAdapter.Tests.csproj | 4 +- .../NUnitEngineTests/NUnitDiscoveryTests.cs | 49 +++++++++++++++++-- 7 files changed, 66 insertions(+), 27 deletions(-) rename src/NUnitTestAdapter/Properties/{AssemblyInfo.cs => AssemblyInfoExtra.cs} (59%) diff --git a/build.cake b/build.cake index 1ca9b84b..8ee08347 100644 --- a/build.cake +++ b/build.cake @@ -13,9 +13,9 @@ var configuration = Argument("configuration", "Release"); ////////////////////////////////////////////////////////////////////// -var version = "4.4.2"; +var version = "4.5.0"; -var modifier = ""; +var modifier = "-alpha.3"; var dbgSuffix = configuration.ToLower() == "debug" ? "-dbg" : ""; diff --git a/nuget.config b/nuget.config index 01dd41bc..8f1bcc0a 100644 --- a/nuget.config +++ b/nuget.config @@ -3,6 +3,6 @@ - + \ No newline at end of file diff --git a/src/NUnitTestAdapter/AdapterSettings.cs b/src/NUnitTestAdapter/AdapterSettings.cs index e0b866cf..65cc94ce 100644 --- a/src/NUnitTestAdapter/AdapterSettings.cs +++ b/src/NUnitTestAdapter/AdapterSettings.cs @@ -712,7 +712,8 @@ public T MapEnum(string setting, T defaultValue) public enum ExplicitModeEnum { Strict, - Relaxed + Relaxed, + None } public enum OutputXmlFolderMode diff --git a/src/NUnitTestAdapter/NUnit.TestAdapter.csproj b/src/NUnitTestAdapter/NUnit.TestAdapter.csproj index 6f14e4d7..1c42cb4f 100644 --- a/src/NUnitTestAdapter/NUnit.TestAdapter.csproj +++ b/src/NUnitTestAdapter/NUnit.TestAdapter.csproj @@ -4,12 +4,21 @@ NUnit3.TestAdapter NUnit.VisualStudio.TestAdapter - + netcoreapp3.1 - net462;netcoreapp3.1 - false + + true https://github.com/nunit/nunit3-vs-adapter true + 4.5.0.0 + 4.5.0.0 + en + NUnit3 Test Adapter for Visual Studio + Copyright © 2011-2021 Charlie Poole, 2014-2023 Terje Sandstrom + A package containing the NUnit3 TestAdapter for Visual Studio 2012 onwards. + The package works with Visual Studio 2012 and newer, dotnet test and VSTest.Console. + NUnit Project + NUnit3TestAdapter @@ -24,7 +33,7 @@ - + diff --git a/src/NUnitTestAdapter/Properties/AssemblyInfo.cs b/src/NUnitTestAdapter/Properties/AssemblyInfoExtra.cs similarity index 59% rename from src/NUnitTestAdapter/Properties/AssemblyInfo.cs rename to src/NUnitTestAdapter/Properties/AssemblyInfoExtra.cs index 528247a1..ba1a2c80 100644 --- a/src/NUnitTestAdapter/Properties/AssemblyInfo.cs +++ b/src/NUnitTestAdapter/Properties/AssemblyInfoExtra.cs @@ -4,24 +4,14 @@ using System; using System.Reflection; -using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -[assembly: AssemblyTitle("NUnit3 Test Adapter for Visual Studio")] -[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-2023 Terje Sandstrom")] +// See https://learn.microsoft.com/en-us/dotnet/core/project-sdk/msbuild-props for which properties are in the csproj and which are not. + [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] [assembly: CLSCompliant(false)] -[assembly: NeutralResourcesLanguage("en-US")] - [assembly: ComVisible(false)] - [assembly: Guid("c0aad5e4-b486-49bc-b3e8-31e01be6fefe")] -[assembly: AssemblyVersion("4.4.0.0")] -[assembly: AssemblyFileVersion("4.4.0.0")] - [assembly: InternalsVisibleTo("NUnit.VisualStudio.TestAdapter.Tests, PublicKey=002400000480000094000000060200000024000052534131000400000100010029b97dea816272cc4ea44cf3cf666f8150d6dfe1274b6c2e6c4d54259b756888ec08ad6dd3ea0f540b30408b948ae5f39cf0c7b210abdec267b367ce1eccab97d5c6c02ee67090827ffd699544fa2add4849b45a1901eac08495bfee0397fba3946ff3912ce0b9a497818e418a77a0c8db4ca1780e7b6f6dd6911395fcc0faba")] diff --git a/src/NUnitTestAdapterTests/NUnit.TestAdapter.Tests.csproj b/src/NUnitTestAdapterTests/NUnit.TestAdapter.Tests.csproj index 3708c5ee..50dd3106 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 - net462;netcoreapp3.1 - + + netcoreapp3.1 true true diff --git a/src/NUnitTestAdapterTests/NUnitEngineTests/NUnitDiscoveryTests.cs b/src/NUnitTestAdapterTests/NUnitEngineTests/NUnitDiscoveryTests.cs index 92eb8b5a..5db9b5fb 100644 --- a/src/NUnitTestAdapterTests/NUnitEngineTests/NUnitDiscoveryTests.cs +++ b/src/NUnitTestAdapterTests/NUnitEngineTests/NUnitDiscoveryTests.cs @@ -1,6 +1,8 @@ using System.Linq; using System.Xml; + using NSubstitute; + using NUnit.Framework; using NUnit.VisualStudio.TestAdapter.NUnitEngine; // ReSharper disable StringLiteralTypo @@ -1007,17 +1009,54 @@ public void ThatDotNetTestWorks() "; - [Test] - public void ThatMixedExplicitTestSourceWorksFor312() + /// + /// See issue 1041 at https://github.com/nunit/nunit3-vs-adapter/issues/1044 + /// + private const string MixedExplicitTestSourceXmlForIssue1041 = + @" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +"; + + [TestCase(MixedExplicitTestSourceXmlForIssue1041, 2, 4)] + [TestCase(MixedExplicitTestSourceXmlForNUnit312, 1, 3)] + public void ThatMixedExplicitTestSourceWorks(string xml, int expectedRunnable, int expectedAll) { var sut = new DiscoveryConverter(logger, settings); var ndr = sut.ConvertXml( - new NUnitResults(XmlHelper.CreateXmlNode(MixedExplicitTestSourceXmlForNUnit312))); + new NUnitResults(XmlHelper.CreateXmlNode(xml))); Assert.Multiple(() => { Assert.That(ndr.IsExplicit, Is.False, "Explicit check fails"); - Assert.That(ndr.TestAssembly.RunnableTestCases.Count, Is.EqualTo(1), "Runnable number fails"); - Assert.That(ndr.TestAssembly.AllTestCases.Count, Is.EqualTo(3), "Can't find all testcases"); + Assert.That(ndr.TestAssembly.RunnableTestCases.Count, Is.EqualTo(expectedRunnable), "Runnable number fails"); + Assert.That(ndr.TestAssembly.AllTestCases.Count, Is.EqualTo(expectedAll), "Can't find all testcases"); }); }