Skip to content

Commit

Permalink
Merge pull request #1491 from nunit/net80-runner
Browse files Browse the repository at this point in the history
Create net80 runner
  • Loading branch information
CharliePoole authored Oct 3, 2024
2 parents 9456170 + fd9ff74 commit e662ebf
Show file tree
Hide file tree
Showing 6 changed files with 128 additions and 27 deletions.
7 changes: 7 additions & 0 deletions NUnitConsole.sln
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "runners", "runners", "{F3E8
ProjectSection(SolutionItems) = preProject
nuget\runners\DotnetToolSettings.xml = nuget\runners\DotnetToolSettings.xml
nuget\runners\nunit.console-runner-with-extensions.nuspec = nuget\runners\nunit.console-runner-with-extensions.nuspec
nuget\runners\nunit.console-runner.net80.nuspec = nuget\runners\nunit.console-runner.net80.nuspec
nuget\runners\nunit.console-runner.netcore.nuspec = nuget\runners\nunit.console-runner.netcore.nuspec
nuget\runners\nunit.console-runner.nuspec = nuget\runners\nunit.console-runner.nuspec
nuget\runners\nunit.console.nuget.addins = nuget\runners\nunit.console.nuget.addins
Expand Down Expand Up @@ -146,6 +147,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InvalidTestNames", "src\Tes
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AppContextTest", "src\TestData\AppContextTest\AppContextTest.csproj", "{E43A3E4B-B050-471B-B43C-0DF60FD44376}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "net8.0", "net8.0", "{303CF83E-2A87-4882-8CAC-3EB59AAD81FC}"
ProjectSection(SolutionItems) = preProject
nuget\runners\net8.0\DotnetToolSettings.xml = nuget\runners\net8.0\DotnetToolSettings.xml
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -258,6 +264,7 @@ Global
{6B550F25-1CA5-4F3E-B631-1ECCD4CB94E4} = {2ECE1CFB-9436-4149-B7E4-1FB1786FDE9F}
{58E18ACC-1F7E-4395-817E-E7EF943E0C77} = {2ECE1CFB-9436-4149-B7E4-1FB1786FDE9F}
{E43A3E4B-B050-471B-B43C-0DF60FD44376} = {2ECE1CFB-9436-4149-B7E4-1FB1786FDE9F}
{303CF83E-2A87-4882-8CAC-3EB59AAD81FC} = {F3E87D0F-6F06-4C0B-AE06-42C0834C3C6E}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D8E4FC26-5422-4C51-8BBC-D1AC0A578711}
Expand Down
9 changes: 9 additions & 0 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ FilePath[] AGENT_PDB_FILES_NETCORE = {
PackageDefinition NUnitConsoleNuGetPackage;
PackageDefinition NUnitConsoleRunnerNuGetPackage;
PackageDefinition NUnitConsoleRunnerNetCorePackage;
PackageDefinition NUnitConsoleRunnerNet80Package;
PackageDefinition NUnitEnginePackage;
PackageDefinition NUnitEngineApiPackage;
PackageDefinition NUnitConsoleRunnerChocolateyPackage;
Expand Down Expand Up @@ -90,6 +91,14 @@ BuildSettings.Packages.AddRange(new PackageDefinition[] {
+ $"NUnit.ConsoleRunner.NetCore.{BuildSettings.PackageVersion}/nunit.exe"),
tests: NetCoreRunnerTests),

NUnitConsoleRunnerNet80Package = new DotNetToolPackage(
id: "NUnit.ConsoleRunner.Net80",
source: BuildSettings.NuGetDirectory + "runners/nunit.console-runner.net80.nuspec",
checks: new PackageCheck[] { HasFiles("nunit-net80.exe") },
testRunner: new ConsoleRunnerSelfTester(BuildSettings.NuGetTestDirectory
+ $"NUnit.ConsoleRunner.Net80.{BuildSettings.PackageVersion}/nunit-net80.exe"),
tests: NetCoreRunnerTests),

NUnitConsoleRunnerChocolateyPackage = new ChocolateyPackage(
id: "nunit-console-runner",
source: BuildSettings.ChocolateyDirectory + "nunit-console-runner.nuspec",
Expand Down
6 changes: 6 additions & 0 deletions nuget/runners/net8.0/DotnetToolSettings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<DotNetCliTool>
<Commands>
<Command Name="nunit-net80" EntryPoint="nunit3-console.dll" Runner="dotnet" />
</Commands>
</DotNetCliTool>
53 changes: 53 additions & 0 deletions nuget/runners/nunit.console-runner.net80.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>NUnit.ConsoleRunner.Net80</id>
<title>NUnit Console Runner (.NET 8.0)</title>
<version>$version$</version>
<authors>Charlie Poole, Rob Prouse</authors>
<owners>Charlie Poole, Rob Prouse</owners>
<license type="file">LICENSE.txt</license>
<projectUrl>https://nunit.org</projectUrl>
<repository type="git" url="https://github.com/nunit/nunit-console"/>
<iconUrl>https://cdn.rawgit.com/nunit/resources/master/images/icon/nunit_256.png</iconUrl>
<icon>images\nunit_256.png</icon>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<summary>.NET Core build of the console runner for the NUnit unit-testing framework.</summary>
<description>
This package includes the .NET 8.0 build of the NUnit console runner and test engine.

Any extensions, if needed, may be installed as separate packages.
</description>
<releaseNotes>https://docs.nunit.org/articles/nunit/release-notes/console-and-engine.html</releaseNotes>
<language>en-US</language>
<tags>nunit test testing tdd runner</tags>
<copyright>Copyright (c) 2021-2024 Charlie Poole, Rob Prouse</copyright>
<packageTypes>
<packageType name="DotnetTool" />
</packageTypes>
</metadata>
<files>
<file src="../../LICENSE.txt" />
<file src="../../NOTICES.txt" />

<file src="net8.0/nunit3-console.exe" target="tools/net8.0/any" />
<file src="net8.0/nunit3-console.pdb" target="tools/net8.0/any" />
<file src="net8.0/nunit3-console.dll" target="tools/net8.0/any" />
<file src="net8.0/nunit3-console.dll.config" target="tools/net8.0/any" />
<file src="net8.0/nunit3-console.deps.json" target="tools/net8.0/any" />
<file src="net8.0/nunit3-console.runtimeconfig.json" target="tools/net8.0/any" />
<file src="net8.0/nunit.engine.core.dll" target="tools/net8.0/any" />
<file src="net8.0/nunit.engine.core.pdb" target="tools/net8.0/any" />
<file src="net8.0/nunit.engine.dll" target="tools/net8.0/any" />
<file src="net8.0/nunit.engine.pdb" target="tools/net8.0/any" />
<file src="net8.0/nunit.engine.api.dll" target="tools/net8.0/any" />
<file src="net8.0/nunit.engine.api.pdb" target="tools/net8.0/any" />
<file src="net8.0/nunit.engine.api.xml" target="tools/net8.0/any" />
<file src="net8.0/testcentric.engine.metadata.dll" target="tools/net8.0/any" />
<file src="net8.0/Microsoft.Extensions.DependencyModel.dll" target="tools/net8.0/any" />
<file src="../../nuget/runners/nunit.console.nuget.addins" target="tools/net8.0/any"/>
<file src="../../nuget/runners/net8.0/DotnetToolSettings.xml" target="tools/net8.0/any"/>

<file src="../../nunit_256.png" target="images"/>
</files>
</package>
Original file line number Diff line number Diff line change
Expand Up @@ -30,37 +30,63 @@ public void ServiceIsStarted()
Assert.That(_driverService.Status, Is.EqualTo(ServiceStatus.Started), "Failed to start service");
}

[TestCaseSource(nameof(DriverSelectionTestCases))]
public void CorrectDriverIsUsed(string fileName, bool skipNonTestAssemblies, Type expectedType)
{
var driver = _driverService.GetDriver(AppDomain.CurrentDomain, Path.Combine(TestContext.CurrentContext.TestDirectory, fileName), null, skipNonTestAssemblies);
Assert.That(driver, Is.InstanceOf(expectedType));
}

#if NET5_0_OR_GREATER
[TestCase("mock-assembly.dll", false, typeof(NUnitNetCore31Driver))]
[TestCase("mock-assembly.dll", true, typeof(NUnitNetCore31Driver))]
//[TestCase("notest-assembly.dll", false, typeof(NUnitNetCore31Driver))]
static TestCaseData[] DriverSelectionTestCases = new[]
{
#if NETFRAMEWORK
new TestCaseData("mock-assembly.dll", false, typeof(NUnit3FrameworkDriver)),
new TestCaseData("mock-assembly.dll", true, typeof(NUnit3FrameworkDriver)),
new TestCaseData("notest-assembly.dll", false, typeof(NUnit3FrameworkDriver)),
#elif NET5_0_OR_GREATER
new TestCaseData("mock-assembly.dll", false, typeof(NUnitNetCore31Driver)),
new TestCaseData("mock-assembly.dll", true, typeof(NUnitNetCore31Driver)),
//new TestCaseData("notest-assembly.dll", false, typeof(NUnitNetCore31Driver)),
#elif NETCOREAPP3_1
[TestCase("mock-assembly.dll", false, typeof(NUnitNetCore31Driver))]
[TestCase("mock-assembly.dll", true, typeof(NUnitNetCore31Driver))]
[TestCase("notest-assembly.dll", false, typeof(NUnitNetCore31Driver))]
new TestCaseData("mock-assembly.dll", false, typeof(NUnitNetCore31Driver)),
new TestCaseData("mock-assembly.dll", true, typeof(NUnitNetCore31Driver)),
new TestCaseData("notest-assembly.dll", false, typeof(NUnitNetCore31Driver)),
// TODO: This is never used. We need to test net standard driver in some way, possibly
// by forcing it's use in a separate test.
#elif NETCOREAPP2_1
[TestCase("mock-assembly.dll", false, typeof(NUnitNetStandardDriver))]
[TestCase("mock-assembly.dll", true, typeof(NUnitNetStandardDriver))]
[TestCase("notest-assembly.dll", false, typeof(NUnitNetStandardDriver))]
#else
[TestCase("mock-assembly.dll", false, typeof(NUnit3FrameworkDriver))]
[TestCase("mock-assembly.dll", true, typeof(NUnit3FrameworkDriver))]
[TestCase("notest-assembly.dll", false, typeof(NUnit3FrameworkDriver))]
#endif
[TestCase("mock-assembly.pdb", false, typeof(InvalidAssemblyFrameworkDriver))]
[TestCase("mock-assembly.pdb", true, typeof(InvalidAssemblyFrameworkDriver))]
[TestCase("junk.dll", false, typeof(InvalidAssemblyFrameworkDriver))]
[TestCase("junk.dll", true, typeof(InvalidAssemblyFrameworkDriver))]
[TestCase("nunit.engine.core.dll", false, typeof(InvalidAssemblyFrameworkDriver))]
[TestCase("nunit.engine.core.dll", true, typeof(SkippedAssemblyFrameworkDriver))]
#if !NET5_0_OR_GREATER // Not yet working
[TestCase("notest-assembly.dll", true, typeof(SkippedAssemblyFrameworkDriver))]
new TestCaseData("mock-assembly.dll", false, typeof(NUnitNetStandardDriver)),
new TestCaseData("mock-assembly.dll", true, typeof(NUnitNetStandardDriver)),
new TestCaseData("notest-assembly.dll", false, typeof(NUnitNetStandardDriver)),
#endif
public void CorrectDriverIsUsed(string fileName, bool skipNonTestAssemblies, Type expectedType)
// Invalid cases should work with all target runtimes
new TestCaseData("mock-assembly.pdb", false, typeof(InvalidAssemblyFrameworkDriver)),
new TestCaseData("mock-assembly.pdb", true, typeof(InvalidAssemblyFrameworkDriver)),
new TestCaseData("junk.dll", false, typeof(InvalidAssemblyFrameworkDriver)),
new TestCaseData("junk.dll", true, typeof(InvalidAssemblyFrameworkDriver)),
new TestCaseData("nunit.engine.core.dll", false, typeof(InvalidAssemblyFrameworkDriver)),
new TestCaseData("nunit.engine.core.dll", true, typeof(SkippedAssemblyFrameworkDriver))
//#if !NET5_0_OR_GREATER // Not yet working
// new TestCaseData"notest-assembly.dll", true, typeof(SkippedAssemblyFrameworkDriver))
//#endif
};

[Test]
public void EnsureWeHaveSomeValidTestCases()
{
var driver = _driverService.GetDriver(AppDomain.CurrentDomain, Path.Combine(TestContext.CurrentContext.TestDirectory, fileName), null, skipNonTestAssemblies);
Assert.That(driver, Is.InstanceOf(expectedType));
// We currently build these tests for net462, net 8.0, net 6.0 and net core 3.1.
// This test is needed because of the conditional compilation used in generating
// the test cases. If the test project is updated to add a new target runtime,
// and no test cases are added for that runtime, this test will fail.
foreach (var testcase in DriverSelectionTestCases)
{
// Third argument is the Type of the driver
var driverType = testcase.Arguments[2] as Type;
if (!(driverType.BaseType == typeof(NotRunnableFrameworkDriver)))
break;

// All expected drivers derive from NotRunnableFrameworkDriver
Assert.Fail("Only invalid test cases were provided for this runtime. Update DriverServiceTests.cs to include some valid cases.");
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ private static IEnumerable<string> GetRuntimeList()
}
catch (Exception)
{
// Failed to start dotnet command. Assume no versions are installed and just r eturn just return
// Failed to start dotnet command. Assume no versions are installed and just return
yield break;
}

Expand Down

0 comments on commit e662ebf

Please sign in to comment.