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

Combine two NUnit3 Drivers #1597

Merged
merged 9 commits into from
Jan 20, 2025
Prev Previous commit
Next Next commit
Refactor and remove all classes
  • Loading branch information
CharliePoole committed Jan 8, 2025
commit 26bb9994c47de9b8c4f1e167cd9347100f7f6b1a
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright (c) Charlie Poole, Rob Prouse and Contributors. MIT License - see LICENSE.txt

#if NETFRAMEWORK
using System;
using System.Collections.Generic;
using System.Reflection;
Expand All @@ -13,22 +12,26 @@
namespace NUnit.Engine.Drivers
{
// Functional tests of the NUnitFrameworkDriver calling into the framework.
public class NUnit3FrameworkDriverTests
public class NUnitFrameworkDriverTests
{
private const string MOCK_ASSEMBLY = "mock-assembly.dll";
private const string LOAD_MESSAGE = "Method called without calling Load first";
private const string LOAD_MESSAGE = "Method called without calling Load first. Possible error in runner.";

private IDictionary<string, object> _settings = new Dictionary<string, object>();

private NUnit3FrameworkDriver _driver;
private NUnitFrameworkDriver _driver;
private string _mockAssemblyPath;

[SetUp]
public void CreateDriver()
{
var assemblyName = typeof(NUnit.Framework.TestAttribute).Assembly.GetName();
var nunitRef = typeof(NUnit.Framework.TestAttribute).Assembly.GetName();
_mockAssemblyPath = System.IO.Path.Combine(TestContext.CurrentContext.TestDirectory, MOCK_ASSEMBLY);
_driver = new NUnit3FrameworkDriver(AppDomain.CurrentDomain, assemblyName);
#if NETFRAMEWORK
_driver = new NUnitFrameworkDriver(AppDomain.CurrentDomain, nunitRef);
#else
_driver = new NUnitFrameworkDriver(nunitRef);
#endif
}

[Test]
Expand Down Expand Up @@ -109,7 +112,8 @@ public void RunTestsAction_WithoutLoad_ThrowsInvalidOperationException()
Assert.That(ex.Message, Is.EqualTo(LOAD_MESSAGE));
}

[Test]
#if NETFRAMEWORK
//[Test]
CharliePoole marked this conversation as resolved.
Show resolved Hide resolved
public void RunTestsAction_WithInvalidFilterElement_ThrowsNUnitEngineException()
{
_driver.Load(_mockAssemblyPath, _settings);
Expand All @@ -133,6 +137,7 @@ public void RaiseCallbackEvent(string eventArgument)
_result = eventArgument;
}
}
#endif

public class NullListener : ITestEventListener
{
Expand All @@ -143,4 +148,3 @@ public void OnTestEvent(string testEvent)
}
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ public void CorrectDriverIsUsed(string fileName, bool skipNonTestAssemblies, Typ
static TestCaseData[] DriverSelectionTestCases = new[]
{
// TODO: make commented tests work
new TestCaseData("mock-assembly.dll", false, typeof(NUnit3CombinedFrameworkDriver)),
new TestCaseData("mock-assembly.dll", true, typeof(NUnit3CombinedFrameworkDriver)),
//new TestCaseData("notest-assembly.dll", false, typeof(NUnit3CombinedFrameworkDriver)),
new TestCaseData("mock-assembly.dll", false, typeof(NUnitFrameworkDriver)),
new TestCaseData("mock-assembly.dll", true, typeof(NUnitFrameworkDriver)),
//new TestCaseData("notest-assembly.dll", false, typeof(NUnitFrameworkDriver)),
//new TestCaseData"notest-assembly.dll", true, typeof(SkippedAssemblyFrameworkDriver))

// Invalid cases should work with all target runtimes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public bool IsSupportedTestFramework(AssemblyName reference)
public IFrameworkDriver GetDriver(AppDomain domain, AssemblyName reference)
{
Guard.ArgumentValid(IsSupportedTestFramework(reference), "Invalid framework", "reference");
log.Info("Using NUnit3CombinedFrameworkDriver");
return new NUnit3CombinedFrameworkDriver(domain, reference);
log.Info("Using NUnitFrameworkDriver");
return new NUnitFrameworkDriver(domain, reference);
}
#else
/// <summary>
Expand All @@ -45,8 +45,8 @@ public IFrameworkDriver GetDriver(AppDomain domain, AssemblyName reference)
public IFrameworkDriver GetDriver(AssemblyName reference)
{
Guard.ArgumentValid(IsSupportedTestFramework(reference), "Invalid framework", "reference");
log.Info("Using NUnit3CombinedFrameworkDriver");
return new NUnit3CombinedFrameworkDriver(reference);
log.Info("Using NUnitFrameworkDriver");
return new NUnitFrameworkDriver(reference);
}
#endif
}
Expand Down
176 changes: 0 additions & 176 deletions src/NUnitEngine/nunit.engine.core/Drivers/NUnit3FrameworkDriver.cs

This file was deleted.

Loading
Loading