Skip to content

Commit

Permalink
Merge pull request #1496 from nunit/issue-1418
Browse files Browse the repository at this point in the history
Test the NUnit V2 driver extension
  • Loading branch information
CharliePoole authored Oct 7, 2024
2 parents faeafe1 + dee8764 commit 96c2dad
Show file tree
Hide file tree
Showing 10 changed files with 399 additions and 26 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/NUnitConsoleAndEngine.CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@ jobs:
path: "build-results/*.binlog"
# if-no-files-found: error

- name: 🪵 Upload InternalTrace logs
if: always()
uses: actions/upload-artifact@v4
with:
name: InternalTraceLogs
# This path is defined in build-settings.cake
path: "*.log"
# if-no-files-found: error

- name: 💾 Upload test results
uses: actions/upload-artifact@v4
if: always()
Expand Down
7 changes: 7 additions & 0 deletions NUnitConsole.sln
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "net8.0", "net8.0", "{303CF8
nuget\runners\net8.0\DotnetToolSettings.xml = nuget\runners\net8.0\DotnetToolSettings.xml
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "mock-assembly-v2", "src\TestData\mock-assembly-v2\mock-assembly-v2.csproj", "{AD40CA55-35CC-41CA-85F5-8FDA4ECAFF78}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -230,6 +232,10 @@ Global
{E43A3E4B-B050-471B-B43C-0DF60FD44376}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E43A3E4B-B050-471B-B43C-0DF60FD44376}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E43A3E4B-B050-471B-B43C-0DF60FD44376}.Release|Any CPU.Build.0 = Release|Any CPU
{AD40CA55-35CC-41CA-85F5-8FDA4ECAFF78}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AD40CA55-35CC-41CA-85F5-8FDA4ECAFF78}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AD40CA55-35CC-41CA-85F5-8FDA4ECAFF78}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AD40CA55-35CC-41CA-85F5-8FDA4ECAFF78}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -265,6 +271,7 @@ Global
{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}
{AD40CA55-35CC-41CA-85F5-8FDA4ECAFF78} = {2ECE1CFB-9436-4149-B7E4-1FB1786FDE9F}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D8E4FC26-5422-4C51-8BBC-D1AC0A578711}
Expand Down
26 changes: 25 additions & 1 deletion build.cake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Load the recipe
#load nuget:?package=NUnit.Cake.Recipe&version=1.2.0-dev00007
#load nuget:?package=NUnit.Cake.Recipe&version=1.2.0-dev00009
// Comment out above line and uncomment below for local tests of recipe changes
//#load ../NUnit.Cake.Recipe/recipe/*.cake

Expand Down Expand Up @@ -189,6 +189,30 @@ BuildSettings.Packages.AddRange(new PackageDefinition[] {
})
});

Task("BuildZipPackage")
.Does(() =>
{
NUnitConsoleZipPackage.BuildPackage();
});

Task("InstallZipPackage")
.Does(() =>
{
NUnitConsoleZipPackage.InstallPackage();
});

Task("VerifyZipPackage")
.Does(() =>
{
NUnitConsoleZipPackage.VerifyPackage();
});

Task("TestZipPackage")
.Does(() =>
{
NUnitConsoleZipPackage.RunPackageTests();
});

// Adhoc code to check content of a dotnet standalone executable
// TODO: Incorporate this in the recipe itself

Expand Down
2 changes: 2 additions & 0 deletions choco/nunit.console.choco.agent.addins
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Extensions built for a single runtime target
../../../../nunit-extension-*/tools/ # find extensions installed under chocolatey
../../../../../nunit-extension-*/tools/ # find extensions installed under chocolatey

# Extensions built for multiple targets
../../../../nunit-extension-*/tools/*/ # find extensions installed under chocolatey
../../../../../nunit-extension-*/tools/*/ # find extensions installed under chocolatey
81 changes: 58 additions & 23 deletions package-tests.cake
Original file line number Diff line number Diff line change
Expand Up @@ -200,63 +200,98 @@ StandardRunnerTests.Add(new PackageTest(
// RUN TESTS USING EACH OF OUR EXTENSIONS
//////////////////////////////////////////////////////////////////////

// NUnit Project Loader Test
StandardRunnerTests.Add(new PackageTest(
1, "NUnitProjectTest",
"Run NUnit project with mock-assembly.dll built for .NET 4.6.2 and 6.0",
"../../NetFXTests.nunit --config=Release --trace=Debug",
new MockAssemblyExpectedResult("net-4.6.2", "netcore-6.0"),
KnownExtensions.NUnitProjectLoader.SetVersion("3.8.0")));

// V2 Result Writer Test
StandardRunnerTests.Add(new PackageTest(
1, "V2ResultWriterTest",
"Run mock-assembly under .NET 6.0 and produce V2 output",
"testdata/net6.0/mock-assembly.dll --result=TestResult.xml --result=NUnit2TestResult.xml;format=nunit2",
new MockAssemblyExpectedResult("netcore-6.0"),
KnownExtensions.NUnitV2ResultWriter.SetVersion("3.8.0")));

// VS Project Loader Tests
StandardRunnerTests.Add(new PackageTest(
1, "VSProjectLoaderTest_Project",
"Run mock-assembly using the .csproj file",
"../../src/TestData/mock-assembly/mock-assembly.csproj --config=Release",
new MockAssemblyExpectedResult("net462", "netcore-3.1", "netcore-6.0", "netcore-7.0", "netcore-8.0"),
KnownExtensions.VSProjectLoader.SetVersion("3.9.0")));

static ExpectedResult MockAssemblySolutionResult = new ExpectedResult("Failed")
{
Total = 37 * 5,
Passed = 23 * 5,
Failed = 5 * 5,
Warnings = 1 * 5,
Inconclusive = 1 * 5,
Skipped = 7 * 5,
Assemblies = new ExpectedAssemblyResult[]
{
new ExpectedAssemblyResult("mock-assembly.dll", "net-4.6.2"),
new ExpectedAssemblyResult("mock-assembly.dll", "netcore-3.1"),
new ExpectedAssemblyResult("mock-assembly.dll", "netcore-6.0"),
new ExpectedAssemblyResult("mock-assembly.dll", "netcore-7.0"),
new ExpectedAssemblyResult("mock-assembly.dll", "netcore-8.0"),
new ExpectedAssemblyResult("notest-assembly.dll", "net-4.6.2"),
new ExpectedAssemblyResult("notest-assembly.dll", "netcore-3.1"),
new ExpectedAssemblyResult("notest-assembly.dll", "netstandard-2.0"),
new ExpectedAssemblyResult("WpfApp.exe")
}
};

StandardRunnerTests.Add(new PackageTest(
1, "VSProjectLoaderTest_Solution",
"Run mock-assembly using the .sln file",
"../../src/TestData/TestData.sln --config=Release --trace=Debug",
MockAssemblySolutionResult,
new ExpectedResult("Failed")
{
Total = 37 * 5,
Passed = 23 * 5,
Failed = 5 * 5,
Warnings = 1 * 5,
Inconclusive = 1 * 5,
Skipped = 7 * 5,
Assemblies = new ExpectedAssemblyResult[]
{
new ExpectedAssemblyResult("mock-assembly.dll", "net-4.6.2"),
new ExpectedAssemblyResult("mock-assembly.dll", "netcore-3.1"),
new ExpectedAssemblyResult("mock-assembly.dll", "netcore-6.0"),
new ExpectedAssemblyResult("mock-assembly.dll", "netcore-7.0"),
new ExpectedAssemblyResult("mock-assembly.dll", "netcore-8.0"),
new ExpectedAssemblyResult("notest-assembly.dll", "net-4.6.2"),
new ExpectedAssemblyResult("notest-assembly.dll", "netcore-3.1"),
new ExpectedAssemblyResult("notest-assembly.dll", "netstandard-2.0"),
new ExpectedAssemblyResult("WpfApp.exe")
}
},
KnownExtensions.VSProjectLoader.SetVersion("3.9.0")));

// TeamCity Event Listener Test
StandardRunnerTests.Add(new PackageTest(
1, "TeamCityListenerTest",
"Run mock-assembly with --teamcity enabled",
"testdata/net462/mock-assembly.dll --teamcity",
new MockAssemblyExpectedResult("net-4.6.2"),
new ExtensionSpecifier("NUnit.Extension.TeamCityEventListener", "nunit-extension-teamcity-event-listener", "1.0.7")));

// V2 Framework Driver Tests
StandardRunnerTests.Add(new PackageTest(
1, "V2FrameworkDriverTest",
"Run mock-assembly-v2 using the V2 Driver in process",
"v2-tests/net462/mock-assembly-v2.dll --inprocess",
new ExpectedResult("Failed")
{
Total = 28,
Passed = 18,
Failed = 5,
Warnings = 0,
Inconclusive = 1,
Skipped = 4,
Assemblies = new ExpectedAssemblyResult[] { new ExpectedAssemblyResult("mock-assembly-v2.dll", "net-4.6.2") }
},
new ExtensionSpecifier("NUnit.Extension.NUnitV2Driver", "nunit-extension-nunit-v2-driver", "3.9.0")));

StandardRunnerTests.Add(new PackageTest(
1, "V2FrameworkDriverTest",
"Run mock-assembly-v2 using the V2 Driver out of process",
"v2-tests/net462/mock-assembly-v2.dll --trace:Debug",
new ExpectedResult("Failed")
{
Total = 28,
Passed = 18,
Failed = 5,
Warnings = 0,
Inconclusive = 1,
Skipped = 4,
Assemblies = new ExpectedAssemblyResult[] { new ExpectedAssemblyResult("mock-assembly-v2.dll", "net-4.6.2") }
},
new ExtensionSpecifier("NUnit.Extension.NUnitV2Driver", "nunit-extension-nunit-v2-driver", "3.9.0")));

//////////////////////////////////////////////////////////////////////
// SPECIAL CASES
//////////////////////////////////////////////////////////////////////
Expand Down
8 changes: 7 additions & 1 deletion src/NUnitEngine/nunit-agent/nunit-agent.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@
<ItemGroup>
<Compile Include="..\nunit.engine.core\Internal\ExceptionHelper.cs" Link="ExceptionHelper.cs" />
</ItemGroup>


<ItemGroup Condition="'$(TargetFramework)'=='net462'">
<Content Include="nunit.agent.addins">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>

<ItemGroup>
<Content Include="..\..\..\nunit.ico">
<Link>nunit.ico</Link>
Expand Down
5 changes: 5 additions & 0 deletions src/NUnitEngine/nunit-agent/nunit.agent.addins
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
../../net462/addins/nunit.v2.driver.dll
../../net462/addins/nunit-v2-result-writer.dll
../../net462/addins/nunit-project-loader.dll
../../net462/addins/vs-project-loader.dll
../../net462/addins/teamcity-event-listener.dll
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public IFrameworkDriver GetDriver(AppDomain domain, AssemblyName reference)

return AppDomain.CurrentDomain.CreateInstanceFromAndUnwrap(
_driverNode.AssemblyPath, _driverNode.TypeName,
false, 0, null, null, null, null) as IFrameworkDriver;
false, 0, null, new[] { domain }, null, null) as IFrameworkDriver;
}
}
}
Expand Down
Loading

0 comments on commit 96c2dad

Please sign in to comment.