Skip to content

Commit

Permalink
Added engine with fix for NUnit 4 (#1081)
Browse files Browse the repository at this point in the history
  • Loading branch information
OsirisTerje authored Mar 19, 2023
1 parent 7a66b9b commit ea2ea94
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 27 deletions.
4 changes: 2 additions & 2 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -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" : "";
Expand Down
2 changes: 1 addition & 1 deletion nuget.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
<packageSources>
<clear />
<add key="nuget" value="https://api.nuget.org/v3/index.json" />
<!--<add key="Local" value="c:\nuget" />-->
<add key="Local" value="c:\nuget" />
</packageSources>
</configuration>
3 changes: 2 additions & 1 deletion src/NUnitTestAdapter/AdapterSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,8 @@ public T MapEnum<T>(string setting, T defaultValue)
public enum ExplicitModeEnum
{
Strict,
Relaxed
Relaxed,
None
}

public enum OutputXmlFolderMode
Expand Down
17 changes: 13 additions & 4 deletions src/NUnitTestAdapter/NUnit.TestAdapter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,21 @@
<AssemblyName>NUnit3.TestAdapter</AssemblyName>
<!--<AssemblyName>NUnit3.TestAdapterDebug</AssemblyName>-->
<RootNamespace>NUnit.VisualStudio.TestAdapter</RootNamespace>
<!--<TargetFramework>netcoreapp3.1</TargetFramework>-->
<TargetFramework>netcoreapp3.1</TargetFramework>
<!-- For testing and debugging-->
<TargetFrameworks>net462;netcoreapp3.1</TargetFrameworks>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<!--<TargetFrameworks>net462;netcoreapp3.1</TargetFrameworks>-->
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
<SourceLinkOriginUrl>https://github.com/nunit/nunit3-vs-adapter</SourceLinkOriginUrl>
<SourceLinkCreate>true</SourceLinkCreate>
<AssemblyVersion>4.5.0.0</AssemblyVersion>
<FileVersion>4.5.0.0</FileVersion>
<NeutralLanguage>en</NeutralLanguage>
<Title>NUnit3 Test Adapter for Visual Studio</Title>
<Copyright>Copyright © 2011-2021 Charlie Poole, 2014-2023 Terje Sandstrom</Copyright>
<Description>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.</Description>
<Company>NUnit Project</Company>
<Product>NUnit3TestAdapter</Product>
</PropertyGroup>

<PropertyGroup>
Expand All @@ -24,7 +33,7 @@

<ItemGroup>
<PackageReference Include="SourceLink.Create.CommandLine" Version="2.8.3" PrivateAssets="All" />
<PackageReference Include="nunit.engine" Version="3.15.3-net8-3153-1" />
<PackageReference Include="nunit.engine" Version="3.15.4-pre00001" />
<PackageReference Include="TestCentric.Metadata" Version="1.7.1" Aliases="TestCentric" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
4 changes: 2 additions & 2 deletions src/NUnitTestAdapterTests/NUnit.TestAdapter.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<IsTestProject>true</IsTestProject>
<RootNamespace>NUnit.VisualStudio.TestAdapter.Tests</RootNamespace>
<AssemblyName>NUnit.VisualStudio.TestAdapter.Tests</AssemblyName>
<TargetFrameworks>net462;netcoreapp3.1</TargetFrameworks>
<!--<TargetFrameworks>netcoreapp3.1</TargetFrameworks>-->
<!--<TargetFrameworks>net462;netcoreapp3.1</TargetFrameworks>-->
<TargetFrameworks>netcoreapp3.1</TargetFrameworks>
<!-- For testing and debugging-->
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
Expand Down
49 changes: 44 additions & 5 deletions src/NUnitTestAdapterTests/NUnitEngineTests/NUnitDiscoveryTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System.Linq;
using System.Xml;

using NSubstitute;

using NUnit.Framework;
using NUnit.VisualStudio.TestAdapter.NUnitEngine;
// ReSharper disable StringLiteralTypo
Expand Down Expand Up @@ -1007,17 +1009,54 @@ public void ThatDotNetTestWorks()
</test-suite>
</test-run>";

[Test]
public void ThatMixedExplicitTestSourceWorksFor312()
/// <summary>
/// See issue 1041 at https://github.com/nunit/nunit3-vs-adapter/issues/1044
/// </summary>
private const string MixedExplicitTestSourceXmlForIssue1041 =
@"<test-run id='0' name='Issue1044.dll' fullname='d:\repos\NUnit\nunit3-vs-adapter.issues\Issue1044\bin\Debug\net7.0\Issue1044.dll' runstate='Runnable' testcasecount='4'>
<test-suite type='Assembly' id='0-1009' name='Issue1044.dll' fullname='d:/repos/NUnit/nunit3-vs-adapter.issues/Issue1044/bin/Debug/net7.0/Issue1044.dll' runstate='Runnable' testcasecount='4'>
<environment framework-version='3.13.3.0' clr-version='7.0.0' os-version='Microsoft Windows 10.0.19044' platform='Win32NT' cwd='d:\repos\NUnit\nunit3-vs-adapter.issues\Issue1044\bin\Debug\net7.0' machine-name='DESKTOP-SIATMVB' user='TerjeSandstrom' user-domain='AzureAD' culture='en-US' uiculture='en-US' os-architecture='x64' />
<settings>
<setting name='NumberOfTestWorkers' value='0' />
<setting name='SynchronousEvents' value='False' />
<setting name='InternalTraceLevel' value='Off' />
<setting name='RandomSeed' value='1197244076' />
<setting name='ProcessModel' value='InProcess' />
<setting name='DomainUsage' value='Single' />
<setting name='DefaultTestNamePattern' value='{m}{a}' />
<setting name='WorkDirectory' value='d:\repos\NUnit\nunit3-vs-adapter.issues\Issue1044\bin\Debug\net7.0' />
</settings>
<properties>
<property name='_PID' value='83292' />
<property name='_APPDOMAIN' value='testhost' />
</properties>
<test-suite type='TestSuite' id='0-1010' name='Issue1041' fullname='Issue1041' runstate='Runnable' testcasecount='4'>
<test-suite type='TestFixture' id='0-1011' name='Tests' fullname='Issue1041.Tests' runstate='Runnable' testcasecount='4'>
<test-suite type='ParameterizedMethod' id='0-1012' name='ExplicitTest' fullname='Issue1041.Tests.ExplicitTest' classname='Issue1041.Tests' runstate='Explicit' testcasecount='2'>
<test-case id='0-1004' name='The test number 1.' fullname='Issue1041.Tests.The test number 1.' methodname='ExplicitTest' classname='Issue1041.Tests' runstate='Explicit' seed='1882810222' />
<test-case id='0-1005' name='The test number 2.' fullname='Issue1041.Tests.The test number 2.' methodname='ExplicitTest' classname='Issue1041.Tests' runstate='Explicit' seed='531831831' />
</test-suite>
<test-suite type='ParameterizedMethod' id='0-1013' name='RegularTest' fullname='Issue1041.Tests.RegularTest' classname='Issue1041.Tests' runstate='Runnable' testcasecount='2'>
<test-case id='0-1001' name='The test number 1.' fullname='Issue1041.Tests.The test number 1.' methodname='RegularTest' classname='Issue1041.Tests' runstate='Runnable' seed='501371230' />
<test-case id='0-1002' name='The test number 2.' fullname='Issue1041.Tests.The test number 2.' methodname='RegularTest' classname='Issue1041.Tests' runstate='Runnable' seed='1044448715' />
</test-suite>
</test-suite>
</test-suite>
</test-suite>
</test-run>";

[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");
});
}

Expand Down

0 comments on commit ea2ea94

Please sign in to comment.