diff --git a/src/NUnitEngine/nunit.engine.core.tests/Drivers/NUnitFrameworkDriverTests.cs b/src/NUnitEngine/nunit.engine.core.tests/Drivers/NUnitFrameworkDriverTests.cs index d317e9b4f..011c6b9c7 100644 --- a/src/NUnitEngine/nunit.engine.core.tests/Drivers/NUnitFrameworkDriverTests.cs +++ b/src/NUnitEngine/nunit.engine.core.tests/Drivers/NUnitFrameworkDriverTests.cs @@ -14,8 +14,8 @@ namespace NUnit.Engine.Drivers // Functional tests of the NUnitFrameworkDriver calling into the framework. #if NETFRAMEWORK [TestFixture("2009")] - [TestFixture("2018")] #endif + [TestFixture("2018")] public class NUnitFrameworkDriverTests { private const string MOCK_ASSEMBLY = "mock-assembly.dll"; @@ -26,13 +26,11 @@ public class NUnitFrameworkDriverTests private NUnitFrameworkDriver _driver; private string _mockAssemblyPath; -#if NETFRAMEWORK private string _whichApi; public NUnitFrameworkDriverTests(string whichApi) { _whichApi = whichApi; } -#endif [SetUp] public void CreateDriver() @@ -125,6 +123,23 @@ public void RunTestsAction_WithoutLoad_ThrowsInvalidOperationException() Assert.That(ex.Message, Is.EqualTo(LOAD_MESSAGE)); } + [Test] + public void RunTestsAction_WithInvalidFilterElement_ThrowsException() + { + _driver.Load(_mockAssemblyPath, _settings); + + var invalidFilter = "foo"; + var ex = Assert.Catch(() => _driver.Run(new NullListener(), invalidFilter)); + + if (_whichApi == "2018") + { + Assert.That(ex, Is.TypeOf()); + Assert.That(ex.InnerException, Is.TypeOf()); + } + else + Assert.That(ex, Is.TypeOf()); + } + #if NETFRAMEWORK // Nested Class tests Api Selection in the driver public class ApiSelectionTests() @@ -146,23 +161,6 @@ public void CorrectApiIsSelected(string nunitVersion, string apiVersion) } } - [Test] - public void RunTestsAction_WithInvalidFilterElement_ThrowsException() - { - _driver.Load(_mockAssemblyPath, _settings); - - var invalidFilter = "foo"; - var ex = Assert.Catch(() => _driver.Run(new NullListener(), invalidFilter)); - - if (_whichApi == "2018") - { - Assert.That(ex, Is.TypeOf()); - Assert.That(ex.InnerException, Is.TypeOf()); - } - else - Assert.That(ex, Is.TypeOf()); - } - private class CallbackEventHandler : System.Web.UI.ICallbackEventHandler { private string? _result; diff --git a/src/NUnitEngine/nunit.engine.core/Drivers/DriverService.cs b/src/NUnitEngine/nunit.engine.core/Drivers/DriverService.cs index 48d33c8d3..802a2e5ff 100644 --- a/src/NUnitEngine/nunit.engine.core/Drivers/DriverService.cs +++ b/src/NUnitEngine/nunit.engine.core/Drivers/DriverService.cs @@ -70,7 +70,7 @@ public IFrameworkDriver GetDriver(AppDomain domain, TestPackage package, string if (platform == "Silverlight" || platform == ".NETPortable" || platform == ".NETStandard" || platform == ".NETCompactFramework") if (skipNonTestAssemblies) - return new SkippedAssemblyFrameworkDriver(assemblyPath, "X"); + return new SkippedAssemblyFrameworkDriver(assemblyPath, package.ID); else return new InvalidAssemblyFrameworkDriver(assemblyPath, package.ID, platform + " test assemblies are not supported by this version of the engine"); diff --git a/src/NUnitEngine/nunit.engine.core/Drivers/NUnitFrameworkApi2009.cs b/src/NUnitEngine/nunit.engine.core/Drivers/NUnitFrameworkApi2009.cs index 4fb9b40fa..acc022a58 100644 --- a/src/NUnitEngine/nunit.engine.core/Drivers/NUnitFrameworkApi2009.cs +++ b/src/NUnitEngine/nunit.engine.core/Drivers/NUnitFrameworkApi2009.cs @@ -64,15 +64,15 @@ public string Load(string testAssemblyPath, IDictionary settings try { - _frameworkController = _testDomain.CreateInstanceAndUnwrap( - _nunitRef.FullName, - CONTROLLER_TYPE, - false, - 0, - null, - new object[] { _testAssemblyPath, idPrefix, settings }, - null, - null).ShouldNotBeNull(); + _frameworkController = _testDomain.CreateInstanceAndUnwrap( + _nunitRef.FullName, + CONTROLLER_TYPE, + false, + 0, + null, + new object[] { _testAssemblyPath, idPrefix, settings }, + null, + null).ShouldNotBeNull(); } catch (BadImageFormatException ex) when (requestedRuntime != null) { @@ -152,10 +152,8 @@ private object CreateObject(string typeName, params object?[]? args) { try { - return _testDomain.CreateInstanceAndUnwrap( - _nunitRef.FullName, typeName, false, 0, null, args, null, null)!; - //return _testDomain.CreateInstanceAndUnwrap( - // _nunitRef.FullName, typeName, false, 0, null, args, null, null)!; + return _testDomain.CreateInstanceAndUnwrap( + _nunitRef.FullName, typeName, false, 0, null, args, null, null)!; } catch (TargetInvocationException ex) { diff --git a/src/NUnitEngine/nunit.engine.core/Drivers/NUnitFrameworkApi2018.cs b/src/NUnitEngine/nunit.engine.core/Drivers/NUnitFrameworkApi2018.cs index 8d5778764..535388f19 100644 --- a/src/NUnitEngine/nunit.engine.core/Drivers/NUnitFrameworkApi2018.cs +++ b/src/NUnitEngine/nunit.engine.core/Drivers/NUnitFrameworkApi2018.cs @@ -40,7 +40,6 @@ public class NUnitFrameworkApi2018 : NUnitFrameworkApi #if NETCOREAPP private TestAssemblyLoadContext? _assemblyLoadContext; - //private Assembly? _testAssembly; private Assembly? _frameworkAssembly; #endif @@ -63,7 +62,7 @@ public string Load(string testAssemblyPath, IDictionary settings log.Info($"Loading {testAssemblyPath} - see separate log file"); _testAssemblyPath = Path.GetFullPath(testAssemblyPath); - var idPrefix = string.IsNullOrEmpty(_driverId) ? "" : _driverId + "-"; + var idPrefix = _driverId + "-"; #if NETFRAMEWORK try @@ -236,10 +235,10 @@ private object ExecuteMethod(MethodInfo? method, params object?[] args) #if NETFRAMEWORK return method.Invoke(_frameworkController, args).ShouldNotBeNull(); #else - using (_assemblyLoadContext.ShouldNotBeNull().EnterContextualReflection()) - { - return method.Invoke(_frameworkController, args).ShouldNotBeNull(); - } + //using (_assemblyLoadContext.ShouldNotBeNull().EnterContextualReflection()) + //{ + return method.Invoke(_frameworkController, args).ShouldNotBeNull(); + //} #endif } diff --git a/src/NUnitEngine/nunit.engine.core/Drivers/NUnitFrameworkDriver.cs b/src/NUnitEngine/nunit.engine.core/Drivers/NUnitFrameworkDriver.cs index 5c082e7cc..b876ba368 100644 --- a/src/NUnitEngine/nunit.engine.core/Drivers/NUnitFrameworkDriver.cs +++ b/src/NUnitEngine/nunit.engine.core/Drivers/NUnitFrameworkDriver.cs @@ -108,7 +108,7 @@ public NUnitFrameworkDriver(string id, AssemblyName nunitRef) /// An id prefix that will be passed to the test framework and used as part of the /// test ids created. /// - public string ID { get; } = string.Empty; + public string ID { get; } /// /// Loads the tests in an assembly. diff --git a/src/NUnitEngine/nunit.engine.core/Runners/TestAgentRunner.cs b/src/NUnitEngine/nunit.engine.core/Runners/TestAgentRunner.cs index 5f2fe6dfc..d71e58f14 100644 --- a/src/NUnitEngine/nunit.engine.core/Runners/TestAgentRunner.cs +++ b/src/NUnitEngine/nunit.engine.core/Runners/TestAgentRunner.cs @@ -136,8 +136,6 @@ public virtual void Unload() { } /// The count of test cases public int CountTestCases(TestFilter filter) { - GetLoadedDriver(); - try { return GetLoadedDriver().CountTestCases(filter.Text);