diff --git a/.github/workflows/NUnitConsoleAndEngine.CI.yml b/.github/workflows/NUnitConsoleAndEngine.CI.yml index 71bd30336..d218973ba 100644 --- a/.github/workflows/NUnitConsoleAndEngine.CI.yml +++ b/.github/workflows/NUnitConsoleAndEngine.CI.yml @@ -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() diff --git a/NUnitConsole.sln b/NUnitConsole.sln index f8919dc54..5a33c0c61 100644 --- a/NUnitConsole.sln +++ b/NUnitConsole.sln @@ -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 @@ -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 @@ -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} diff --git a/build.cake b/build.cake index d310430b2..1c2439f79 100644 --- a/build.cake +++ b/build.cake @@ -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 @@ -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 diff --git a/choco/nunit.console.choco.agent.addins b/choco/nunit.console.choco.agent.addins index ddf5d016b..d326d241b 100644 --- a/choco/nunit.console.choco.agent.addins +++ b/choco/nunit.console.choco.agent.addins @@ -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 diff --git a/package-tests.cake b/package-tests.cake index a0b9e9986..4e0b9ce36 100644 --- a/package-tests.cake +++ b/package-tests.cake @@ -200,6 +200,7 @@ 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", @@ -207,6 +208,7 @@ StandardRunnerTests.Add(new PackageTest( 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", @@ -214,6 +216,7 @@ StandardRunnerTests.Add(new PackageTest( 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", @@ -221,35 +224,34 @@ StandardRunnerTests.Add(new PackageTest( 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", @@ -257,6 +259,39 @@ StandardRunnerTests.Add(new PackageTest( 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 ////////////////////////////////////////////////////////////////////// diff --git a/src/NUnitEngine/nunit-agent/nunit-agent.csproj b/src/NUnitEngine/nunit-agent/nunit-agent.csproj index 71e07baa5..b7ee2341a 100644 --- a/src/NUnitEngine/nunit-agent/nunit-agent.csproj +++ b/src/NUnitEngine/nunit-agent/nunit-agent.csproj @@ -25,7 +25,13 @@ - + + + + PreserveNewest + + + nunit.ico diff --git a/src/NUnitEngine/nunit-agent/nunit.agent.addins b/src/NUnitEngine/nunit-agent/nunit.agent.addins new file mode 100644 index 000000000..74b562fd7 --- /dev/null +++ b/src/NUnitEngine/nunit-agent/nunit.agent.addins @@ -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 diff --git a/src/NUnitEngine/nunit.engine.core/Drivers/NUnit2DriverFactory.cs b/src/NUnitEngine/nunit.engine.core/Drivers/NUnit2DriverFactory.cs index 5ab8ffa2f..8d6994587 100644 --- a/src/NUnitEngine/nunit.engine.core/Drivers/NUnit2DriverFactory.cs +++ b/src/NUnitEngine/nunit.engine.core/Drivers/NUnit2DriverFactory.cs @@ -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; } } } diff --git a/src/TestData/mock-assembly-v2/MockAssembly.cs b/src/TestData/mock-assembly-v2/MockAssembly.cs new file mode 100644 index 000000000..b9439abce --- /dev/null +++ b/src/TestData/mock-assembly-v2/MockAssembly.cs @@ -0,0 +1,269 @@ +// Copyright (c) Charlie Poole, Rob Prouse and Contributors. MIT License - see LICENSE.txt + +using System; +using NUnit.Framework; + +namespace TestCentric.Tests +{ + namespace Assemblies + { + /// + /// Constant definitions for the mock-assembly dll. + /// + public class MockAssembly + { + public static int Classes = 9; + + public static int NamespaceSuites = 6; // assembly, NUnit, Tests, Assemblies, Singletons, TestAssembly + + public static int Tests = MockTestFixture.Tests + + Singletons.OneTestCase.Tests + + TestAssembly.MockTestFixture.Tests + + IgnoredFixture.Tests + + ExplicitFixture.Tests + + BadFixture.Tests + + FixtureWithTestCases.Tests + + ParameterizedFixture.Tests + + GenericFixtureConstants.Tests; + + public static int Suites = MockTestFixture.Suites + + Singletons.OneTestCase.Suites + + TestAssembly.MockTestFixture.Suites + + IgnoredFixture.Suites + + ExplicitFixture.Suites + + BadFixture.Suites + + FixtureWithTestCases.Suites + + ParameterizedFixture.Suites + + GenericFixtureConstants.Suites + + NamespaceSuites; + + public static readonly int Nodes = Tests + Suites; + + public static int ExplicitFixtures = 1; + public static int SuitesRun = Suites - ExplicitFixtures; + + public static int Ignored = MockTestFixture.Ignored + IgnoredFixture.Tests; + public static int Explicit = MockTestFixture.Explicit + ExplicitFixture.Tests; + public static int NotRunnable = MockTestFixture.NotRunnable + BadFixture.Tests; + public static int NotRun = Ignored + Explicit + NotRunnable; + public static int TestsRun = Tests - NotRun; + public static int ResultCount = Tests - Explicit; + + public static int Errors = MockTestFixture.Errors; + public static int Failures = MockTestFixture.Failures; + + public static int Categories = MockTestFixture.Categories; + } + + [TestFixture(Description="Fake Test Fixture")] + [Category("FixtureCategory")] + public class MockTestFixture + { + public static readonly int Tests = 11; + public static readonly int Suites = 1; + + public static readonly int Ignored = 1; + public static readonly int Explicit = 1; + public static readonly int NotRunnable = 2; + public static readonly int NotRun = Ignored + Explicit + NotRunnable; + public static readonly int TestsRun = Tests - NotRun; + public static readonly int ResultCount = Tests - Explicit; + + public static readonly int Failures = 1; + public static readonly int Errors = 1; + + public static readonly int Categories = 5; + public static readonly int MockCategoryTests = 2; + + [Test(Description="Mock Test #1")] + public void MockTest1() + {} + + [Test] + [Category("MockCategory")] + [Property("Severity","Critical")] + [Description("This is a really, really, really, really, really, really, really, really, really, really, really, really, really, really, really, really, really, really, really, really, really, really, really, really, really long description")] + public void MockTest2() + {} + + [Test] + [Category("MockCategory")] + [Category("AnotherCategory")] + public void MockTest3() + { Assert.Pass("Succeeded!"); } + + [Test] + protected static void MockTest5() + {} + + [Test] + public void FailingTest() + { + Assert.Fail("Intentional failure"); + } + + [Test, Property("TargetMethod", "SomeClassName"), Property("Size", 5), /*Property("TargetType", typeof( System.Threading.Thread ))*/] + public void TestWithManyProperties() + {} + + [Test] + [Ignore("ignoring this test method for now")] + [Category("Foo")] + public void MockTest4() + {} + + [Test, Explicit] + [Category( "Special" )] + public void ExplicitlyRunTest() + {} + + [Test] + public void NotRunnableTest( int a, int b) + { + } + + [Test] + public void InconclusiveTest() + { + Assert.Inconclusive("No valid data"); + } + + [Test] + public void TestWithException() + { + MethodThrowsException(); + } + + private void MethodThrowsException() + { + throw new ApplicationException("Intentional Exception"); + } + } + } + + namespace Singletons + { + [TestFixture] + public class OneTestCase + { + public static readonly int Tests = 1; + public static readonly int Suites = 1; + + [Test] + public virtual void TestCase() + {} + } + } + + namespace TestAssembly + { + [TestFixture] + public class MockTestFixture + { + public static readonly int Tests = 1; + public static readonly int Suites = 1; + + [Test] + public void MyTest() + { + } + } + } + + [TestFixture, Ignore] + public class IgnoredFixture + { + public static readonly int Tests = 3; + public static readonly int Suites = 1; + + [Test] + public void Test1() { } + + [Test] + public void Test2() { } + + [Test] + public void Test3() { } + } + + [TestFixture,Explicit] + public class ExplicitFixture + { + public static readonly int Tests = 2; + public static readonly int Suites = 1; + public static readonly int Nodes = Tests + Suites; + + [Test] + public void Test1() { } + + [Test] + public void Test2() { } + } + + [TestFixture] + public class BadFixture + { + public static readonly int Tests = 1; + public static readonly int Suites = 1; + + public BadFixture(int val) { } + + [Test] + public void SomeTest() { } + } + + [TestFixture] + public class FixtureWithTestCases + { + public static readonly int Tests = 4; + public static readonly int Suites = 3; + + [TestCase(2, 2, Result=4)] + [TestCase(9, 11, Result=20)] + public int MethodWithParameters(int x, int y) + { + return x+y; + } + + [TestCase(2, 4)] + [TestCase(9.2, 11.7)] + public void GenericMethod(T x, T y) + { + } + } + + [TestFixture(5)] + [TestFixture(42)] + public class ParameterizedFixture + { + public static readonly int Tests = 4; + public static readonly int Suites = 3; + + public ParameterizedFixture(int num) { } + + [Test] + public void Test1() { } + + [Test] + public void Test2() { } + } + + public class GenericFixtureConstants + { + public static readonly int Tests = 4; + public static readonly int Suites = 3; + } + + [TestFixture(5)] + [TestFixture(11.5)] + public class GenericFixture + { + public GenericFixture(T num){ } + + [Test] + public void Test1() { } + + [Test] + public void Test2() { } + } +} diff --git a/src/TestData/mock-assembly-v2/mock-assembly-v2.csproj b/src/TestData/mock-assembly-v2/mock-assembly-v2.csproj new file mode 100644 index 000000000..5d760a26f --- /dev/null +++ b/src/TestData/mock-assembly-v2/mock-assembly-v2.csproj @@ -0,0 +1,16 @@ + + + + NUnit.Tests + net462 + true + ..\..\nunit.snk + ..\..\..\bin\$(Configuration)\v2-tests\ + true + + + + + + + \ No newline at end of file