Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 1649 #1651

Merged
merged 6 commits into from
Mar 23, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions NUnitConsole.sln
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "nunit.extensibility", "src\
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "nunit.extensibility.tests", "src\NUnitCommon\nunit.extensibility.tests\nunit.extensibility.tests.csproj", "{B22FEE5B-83D4-4021-B066-1B958332D391}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FakeExtensions", "src\NUnitCommon\FakeExtensions\FakeExtensions.csproj", "{E2A4C099-E35D-4E27-B89D-957140ED970F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "nunit.common", "src\NUnitCommon\nunit.common\nunit.common.csproj", "{9D9CAD66-8EDF-4ED0-A222-503BE9B21EC7}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "nunit.common.tests", "src\NUnitCommon\nunit.common.tests\nunit.common.tests.csproj", "{6605DA54-EBF4-4ED1-B5BC-B607AD0CE308}"
Expand All @@ -164,6 +162,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "nunit.agent.core", "src\NUn
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "nunit.agent.core.tests", "src\NUnitCommon\nunit.agent.core.tests\nunit.agent.core.tests.csproj", "{89258A3E-5B62-487A-9AE7-D7672CBF61F1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FakeExtensions", "src\TestData\FakeExtensions\FakeExtensions.csproj", "{608AA86D-4090-33CA-0031-BD324E5A766E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -270,10 +270,6 @@ Global
{B22FEE5B-83D4-4021-B066-1B958332D391}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B22FEE5B-83D4-4021-B066-1B958332D391}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B22FEE5B-83D4-4021-B066-1B958332D391}.Release|Any CPU.Build.0 = Release|Any CPU
{E2A4C099-E35D-4E27-B89D-957140ED970F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E2A4C099-E35D-4E27-B89D-957140ED970F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E2A4C099-E35D-4E27-B89D-957140ED970F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E2A4C099-E35D-4E27-B89D-957140ED970F}.Release|Any CPU.Build.0 = Release|Any CPU
{9D9CAD66-8EDF-4ED0-A222-503BE9B21EC7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9D9CAD66-8EDF-4ED0-A222-503BE9B21EC7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9D9CAD66-8EDF-4ED0-A222-503BE9B21EC7}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand All @@ -290,6 +286,10 @@ Global
{89258A3E-5B62-487A-9AE7-D7672CBF61F1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{89258A3E-5B62-487A-9AE7-D7672CBF61F1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{89258A3E-5B62-487A-9AE7-D7672CBF61F1}.Release|Any CPU.Build.0 = Release|Any CPU
{608AA86D-4090-33CA-0031-BD324E5A766E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{608AA86D-4090-33CA-0031-BD324E5A766E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{608AA86D-4090-33CA-0031-BD324E5A766E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{608AA86D-4090-33CA-0031-BD324E5A766E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -331,11 +331,11 @@ Global
{71DE0F2C-C72B-4CBF-99BE-F2DC0FBEDA24} = {3B30D2E5-1587-4D68-B848-1BDDB3C24BFC}
{49E8B583-37C2-4166-8007-3DB780D01004} = {3B30D2E5-1587-4D68-B848-1BDDB3C24BFC}
{B22FEE5B-83D4-4021-B066-1B958332D391} = {3B30D2E5-1587-4D68-B848-1BDDB3C24BFC}
{E2A4C099-E35D-4E27-B89D-957140ED970F} = {3B30D2E5-1587-4D68-B848-1BDDB3C24BFC}
{9D9CAD66-8EDF-4ED0-A222-503BE9B21EC7} = {3B30D2E5-1587-4D68-B848-1BDDB3C24BFC}
{6605DA54-EBF4-4ED1-B5BC-B607AD0CE308} = {3B30D2E5-1587-4D68-B848-1BDDB3C24BFC}
{4FCFAF1C-1579-4A1C-BAF9-9627E39D7CDA} = {3B30D2E5-1587-4D68-B848-1BDDB3C24BFC}
{89258A3E-5B62-487A-9AE7-D7672CBF61F1} = {3B30D2E5-1587-4D68-B848-1BDDB3C24BFC}
{608AA86D-4090-33CA-0031-BD324E5A766E} = {37D508B2-91E0-4B32-869B-DFF9E68EA213}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D8E4FC26-5422-4C51-8BBC-D1AC0A578711}
Expand Down
2 changes: 1 addition & 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.4.0-alpha.2
#load nuget:?package=NUnit.Cake.Recipe&version=1.4.0-alpha.7
// Comment out above line and uncomment below for local tests of recipe changes
//#load ../NUnit.Cake.Recipe/recipe/*.cake

Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "8.0.101",
"version": "9.0.100",
"rollForward": "feature"
}
}
83 changes: 58 additions & 25 deletions package-tests.cake
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,21 @@ void AddToBothLists(PackageTest test)
NetCoreRunnerTests.Add(test);
}

public static class Extensions
{
// Extensions used in tests, with version specified.
public static ExtensionSpecifier NUnitV2Driver = new ExtensionSpecifier(
"NUnit.Extension.NUnitV2Driver", "nunit-extension-nunit-v2-driver", "3.9.0");
public static ExtensionSpecifier NUnitProjectLoader = new ExtensionSpecifier(
"NUnit.Extension.NUnitProjectLoader", "nunit-extension-nunit-project-loader", "3.8.0");
public static ExtensionSpecifier VSProjectLoader = new ExtensionSpecifier(
"NUnit.Extension.VSProjectLoader", "nunit-extension-vs-project-loader", "3.9.0");
public static ExtensionSpecifier NUnitV2ResultWriter = new ExtensionSpecifier(
"NUnit.Extension.NUnitV2ResultWriter", "nunit-extension-nunit-v2-result-writer", "3.8.0");
public static ExtensionSpecifier TeamCityEventListener = new ExtensionSpecifier(
"NUnit.Extension.TeamCityEventListener", "nunit-extension-teamcity-event-listener", "1.0.9");
}

//////////////////////////////////////////////////////////////////////
// RUN MOCK-ASSEMBLY UNDER EACH RUNTIME
//////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -289,45 +304,63 @@ AddToBothLists(new PackageTest(1, "Net80WPFTest")
ExpectedResult = new ExpectedResult("Passed") { Assemblies = new[] { new ExpectedAssemblyResult("WpfTest.dll", "netcore-8.0") } }
});

//////////////////////////////////////////////////////////////////////
// TESTS OF EXTENSION LISTING
//////////////////////////////////////////////////////////////////////

AddToBothLists(new PackageTest(1, "NoExtensionsInstalled")
{
Description = "List Extensions shows none installed",
Arguments = "--list-extensions",
OutputCheck = new OutputDoesNotContain("Extension:"),
});

AddToBothLists(new PackageTest(1, "ExtensionsInstalledFromAddedDirectory")
{
Description = "List Extensions shows extension from added directory",
Arguments = "--extensionDirectory ../../src/TestData/FakeExtensions --list-extensions --trace:Debug",
OutputCheck = new OutputContains("Extension:", exactly: 5)
});

//////////////////////////////////////////////////////////////////////
// RUN TESTS USING EACH OF OUR EXTENSIONS
//////////////////////////////////////////////////////////////////////

// TODO: Add back extension tests after latest changes to ExtensionManager
// are ported. Most extensions will require an update to work under V4.

//// NUnit Project Loader Tests
//NUnit Project Loader Tests
//StandardRunnerTests.Add(new PackageTest(1, "NUnitProjectTest")
//{
// Description = "Run NUnit project with mock-assembly.dll built for .NET 4.6.2 and 6.0",
// Arguments = "../../MixedTests.nunit --config=Release",
// ExpectedResult = new MockAssemblyExpectedResult("net-4.6.2", "net-6.0"),
// ExtensionsNeeded = new[] { KnownExtensions.NUnitProjectLoader }
// ExtensionsNeeded = new[] { Extensions.NUnitProjectLoader }
//});

//NetCoreRunnerTests.Add(new PackageTest(1, "NUnitProjectTest")
//{
// Description = "Run NUnit project with mock-assembly.dll built for .NET 6.0 and 8.0",
// Arguments = "../../NetCoreTests.nunit --config=Release",
// Arguments = "../../NetCoreTests.nunit --config=Release --trace:Debug",
// ExpectedResult = new MockAssemblyExpectedResult("netcore-6.0", "netcore-8.0"),
// ExtensionsNeeded = new[] { KnownExtensions.NUnitProjectLoader }
// ExtensionsNeeded = new[] { Extensions.NUnitProjectLoader }
//});

//// V2 Result Writer Test
//StandardRunnerTests.Add(new PackageTest(1, "V2ResultWriterTest_Net462")
//{
// Description = "Run mock-assembly under .NET 4.6.2 and produce V2 output",
// Arguments = "testdata/net462/mock-assembly.dll --result=TestResult.xml --result=NUnit2TestResult.xml;format=nunit2 --trace:Debug",
// ExpectedResult = new MockAssemblyExpectedResult("net-4.6.2"),
// ExtensionsNeeded = new[] { KnownExtensions.NUnitV2ResultWriter }
//});
// V2 Result Writer Test
StandardRunnerTests.Add(new PackageTest(1, "V2ResultWriterTest_Net462")
{
Description = "Run mock-assembly under .NET 4.6.2 and produce V2 output",
Arguments = "testdata/net462/mock-assembly.dll --result=TestResult.xml --result=NUnit2TestResult.xml;format=nunit2 --trace:Debug",
ExpectedResult = new MockAssemblyExpectedResult("net-4.6.2"),
ExtensionsNeeded = new[] { Extensions.NUnitV2ResultWriter }
});

//StandardRunnerTests.Add(new PackageTest(1, "V2ResultWriterTest_Net60")
//{
// Description = "Run mock-assembly under .NET 6.0 and produce V2 output",
// Arguments = "testdata/net6.0/mock-assembly.dll --result=TestResult.xml --result=NUnit2TestResult.xml;format=nunit2 --trace:Debug",
// ExpectedResult = new MockAssemblyExpectedResult("netcore-6.0"),
// ExtensionsNeeded = new[] { KnownExtensions.NUnitV2ResultWriter }
// ExtensionsNeeded = new[] { Extensions.NUnitV2ResultWriter }
//});

//// VS Project Loader Tests
Expand All @@ -336,7 +369,7 @@ AddToBothLists(new PackageTest(1, "Net80WPFTest")
// Description = "Run mock-assembly using the .csproj file",
// Arguments = "../../src/TestData/mock-assembly/mock-assembly.csproj --config=Release",
// ExpectedResult = new MockAssemblyExpectedResult("net462", "netcore-3.1", "netcore-6.0", "netcore-7.0", "netcore-8.0"),
// ExtensionsNeeded = new[] { KnownExtensions.VSProjectLoader }
// ExtensionsNeeded = new[] { Extensions.VSProjectLoader }
//});

//StandardRunnerTests.Add(new PackageTest(1, "VSProjectLoaderTest_Solution")
Expand Down Expand Up @@ -364,17 +397,17 @@ AddToBothLists(new PackageTest(1, "Net80WPFTest")
// new ExpectedAssemblyResult("WpfApp.exe")
// }
// },
// ExtensionsNeeded = new[] { KnownExtensions.VSProjectLoader }
// ExtensionsNeeded = new[] { Extensions.VSProjectLoader }
//});

//// TeamCity Event Listener Test
//StandardRunnerTests.Add(new PackageTest(1, "TeamCityListenerTest")
//{
// Description = "Run mock-assembly with --teamcity enabled",
// Arguments = "testdata/net462/mock-assembly.dll --teamcity",
// ExpectedResult = new MockAssemblyExpectedResult("net-4.6.2"),
// ExtensionsNeeded = new[] { KnownExtensions.TeamCityEventListener }
//});
// TeamCity Event Listener Test
StandardRunnerTests.Add(new PackageTest(1, "TeamCityListenerTest")
{
Description = "Run mock-assembly with --teamcity enabled",
Arguments = "testdata/net462/mock-assembly.dll --teamcity --trace:Debug",
ExpectedResult = new MockAssemblyExpectedResult("net-4.6.2"),
ExtensionsNeeded = new[] { Extensions.TeamCityEventListener }
});

//// V2 Framework Driver Tests
//StandardRunnerTests.Add(new PackageTest(1, "V2FrameworkDriverTest")
Expand All @@ -391,7 +424,7 @@ AddToBothLists(new PackageTest(1, "Net80WPFTest")
// Skipped = 4,
// Assemblies = new ExpectedAssemblyResult[] { new ExpectedAssemblyResult("mock-assembly-v2.dll", "net-4.6.2") }
// },
// ExtensionsNeeded = new[] { KnownExtensions.NUnitV2Driver }
// ExtensionsNeeded = new[] { Extensions.NUnitV2Driver }
//});

//StandardRunnerTests.Add(new PackageTest(1, "V2FrameworkDriverTest")
Expand All @@ -408,7 +441,7 @@ AddToBothLists(new PackageTest(1, "Net80WPFTest")
// Skipped = 4,
// Assemblies = new ExpectedAssemblyResult[] { new ExpectedAssemblyResult("mock-assembly-v2.dll", "net-4.6.2") }
// },
// ExtensionsNeeded = new[] { KnownExtensions.NUnitV2Driver }
// ExtensionsNeeded = new[] { Extensions.NUnitV2Driver }
//});

//////////////////////////////////////////////////////////////////////
Expand Down
38 changes: 19 additions & 19 deletions src/NUnitCommon/nunit.extensibility.tests/ExtensionManagerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,24 @@ public class ExtensionManagerTests
typeof(IFrameworkDriver)
};

private static readonly int[] KnownExtensionPointCounts = { 1, 1, 1, 2, 1, 1 };
private static readonly int[] KnownExtensionPointCounts = { 1, 1, 1, 2, 1, 0 };

private const string DUMMY_FRAMEWORK_DRIVER_EXTENSION = "NUnit.Engine.Fakes.DummyFrameworkDriverExtension";
private const string DUMMY_PROJECT_LOADER_EXTENSION = "NUnit.Engine.Fakes.DummyProjectLoaderExtension";
private const string DUMMY_RESULT_WRITER_EXTENSION = "NUnit.Engine.Fakes.DummyResultWriterExtension";
private const string DUMMY_EVENT_LISTENER_EXTENSION = "NUnit.Engine.Fakes.DummyEventListenerExtension";
private const string DUMMY_SERVICE_EXTENSION = "NUnit.Engine.Fakes.DummyServiceExtension";
private const string DUMMY_DISABLED_EXTENSION = "NUnit.Engine.Fakes.DummyDisabledExtension";
private const string DUMMY_NUNIT_V2_DRIVER_EXTENSION = "NUnit.Engine.Fakes.V2DriverExtension";
private const string FAKE_FRAMEWORK_DRIVER_EXTENSION = "NUnit.Engine.Fakes.FakeFrameworkDriverExtension";
private const string FAKE_PROJECT_LOADER_EXTENSION = "NUnit.Engine.Fakes.FakeProjectLoaderExtension";
private const string FAKE_RESULT_WRITER_EXTENSION = "NUnit.Engine.Fakes.FakeResultWriterExtension";
private const string FAKE_EVENT_LISTENER_EXTENSION = "NUnit.Engine.Fakes.FakeEventListenerExtension";
private const string FAKE_SERVICE_EXTENSION = "NUnit.Engine.Fakes.FakeServiceExtension";
private const string FAKE_DISABLED_EXTENSION = "NUnit.Engine.Fakes.FakeDisabledExtension";
private const string FAKE_NUNIT_V2_DRIVER_EXTENSION = "NUnit.Engine.Fakes.V2DriverExtension";

private readonly string[] KnownExtensions = {
DUMMY_FRAMEWORK_DRIVER_EXTENSION,
DUMMY_PROJECT_LOADER_EXTENSION,
DUMMY_RESULT_WRITER_EXTENSION,
DUMMY_EVENT_LISTENER_EXTENSION,
DUMMY_SERVICE_EXTENSION,
DUMMY_DISABLED_EXTENSION,
DUMMY_NUNIT_V2_DRIVER_EXTENSION
FAKE_FRAMEWORK_DRIVER_EXTENSION,
FAKE_PROJECT_LOADER_EXTENSION,
FAKE_RESULT_WRITER_EXTENSION,
FAKE_EVENT_LISTENER_EXTENSION,
FAKE_SERVICE_EXTENSION,
FAKE_DISABLED_EXTENSION
//FAKE_NUNIT_V2_DRIVER_EXTENSION
};
#pragma warning restore 414

Expand Down Expand Up @@ -90,7 +90,7 @@ public void AllKnownExtensionsAreEnabledAsRequired()
{
foreach (var node in _extensionManager.Extensions)
{
var shouldBeEnabled = node.TypeName != DUMMY_DISABLED_EXTENSION;
var shouldBeEnabled = node.TypeName != FAKE_DISABLED_EXTENSION;
Assert.That(node.Enabled, Is.EqualTo(shouldBeEnabled));
}
}
Expand Down Expand Up @@ -132,17 +132,17 @@ public void ExtensionsAreAddedToExtensionPoint(
public void ExtensionMayBeDisabledByDefault()
{
Assert.That(_extensionManager.Extensions,
Has.One.Property(nameof(ExtensionNode.TypeName)).EqualTo(DUMMY_DISABLED_EXTENSION)
Has.One.Property(nameof(ExtensionNode.TypeName)).EqualTo(FAKE_DISABLED_EXTENSION)
.And.Property(nameof(ExtensionNode.Enabled)).False);
}

[Test]
public void DisabledExtensionMayBeEnabled()
{
_extensionManager.EnableExtension(DUMMY_DISABLED_EXTENSION, true);
_extensionManager.EnableExtension(FAKE_DISABLED_EXTENSION, true);

Assert.That(_extensionManager.Extensions,
Has.One.Property(nameof(ExtensionNode.TypeName)).EqualTo(DUMMY_DISABLED_EXTENSION)
Has.One.Property(nameof(ExtensionNode.TypeName)).EqualTo(FAKE_DISABLED_EXTENSION)
.And.Property(nameof(ExtensionNode.Enabled)).True);
}

Expand Down
Loading
Loading