Skip to content

Commit d4f1ed2

Browse files
committed
Fix merge conflict
2 parents 2947d26 + b63739c commit d4f1ed2

35 files changed

+980
-625
lines changed

NUnitConsole.sln

+31
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,16 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WpfTest", "src\TestData\wpf
135135
EndProject
136136
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WpfApp", "src\TestData\WpfApp\WpfApp.csproj", "{93D182B7-2F63-4661-BB32-94F1716CF03F}"
137137
EndProject
138+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "OlderNUnit", "OlderNUnit", "{D31607D2-D689-488B-9F9F-92F47AC1D7F6}"
139+
EndProject
140+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NUnit3.0", "src\TestData\NUnit3.0\NUnit3.0.csproj", "{2448CE80-59AA-41B7-83A0-768BE5520F7A}"
141+
EndProject
142+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NUnit3.0.1", "src\TestData\NUnit3.0.1\NUnit3.0.1.csproj", "{56416AD9-8E7B-4F72-B0E1-E75A024431F8}"
143+
EndProject
144+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NUnit3.2", "src\TestData\NUnit3.2\NUnit3.2.csproj", "{8AFBB856-700A-4CCC-AE0E-9B622178E1E0}"
145+
EndProject
146+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NUnit3.10", "src\TestData\NUnit3.10\NUnit3.10.csproj", "{0555B97D-E918-455B-951C-74EFCDA8790A}"
147+
EndProject
138148
Global
139149
GlobalSection(SolutionConfigurationPlatforms) = preSolution
140150
Debug|Any CPU = Debug|Any CPU
@@ -229,6 +239,22 @@ Global
229239
{93D182B7-2F63-4661-BB32-94F1716CF03F}.Debug|Any CPU.Build.0 = Debug|Any CPU
230240
{93D182B7-2F63-4661-BB32-94F1716CF03F}.Release|Any CPU.ActiveCfg = Release|Any CPU
231241
{93D182B7-2F63-4661-BB32-94F1716CF03F}.Release|Any CPU.Build.0 = Release|Any CPU
242+
{2448CE80-59AA-41B7-83A0-768BE5520F7A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
243+
{2448CE80-59AA-41B7-83A0-768BE5520F7A}.Debug|Any CPU.Build.0 = Debug|Any CPU
244+
{2448CE80-59AA-41B7-83A0-768BE5520F7A}.Release|Any CPU.ActiveCfg = Release|Any CPU
245+
{2448CE80-59AA-41B7-83A0-768BE5520F7A}.Release|Any CPU.Build.0 = Release|Any CPU
246+
{56416AD9-8E7B-4F72-B0E1-E75A024431F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
247+
{56416AD9-8E7B-4F72-B0E1-E75A024431F8}.Debug|Any CPU.Build.0 = Debug|Any CPU
248+
{56416AD9-8E7B-4F72-B0E1-E75A024431F8}.Release|Any CPU.ActiveCfg = Release|Any CPU
249+
{56416AD9-8E7B-4F72-B0E1-E75A024431F8}.Release|Any CPU.Build.0 = Release|Any CPU
250+
{8AFBB856-700A-4CCC-AE0E-9B622178E1E0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
251+
{8AFBB856-700A-4CCC-AE0E-9B622178E1E0}.Debug|Any CPU.Build.0 = Debug|Any CPU
252+
{8AFBB856-700A-4CCC-AE0E-9B622178E1E0}.Release|Any CPU.ActiveCfg = Release|Any CPU
253+
{8AFBB856-700A-4CCC-AE0E-9B622178E1E0}.Release|Any CPU.Build.0 = Release|Any CPU
254+
{0555B97D-E918-455B-951C-74EFCDA8790A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
255+
{0555B97D-E918-455B-951C-74EFCDA8790A}.Debug|Any CPU.Build.0 = Debug|Any CPU
256+
{0555B97D-E918-455B-951C-74EFCDA8790A}.Release|Any CPU.ActiveCfg = Release|Any CPU
257+
{0555B97D-E918-455B-951C-74EFCDA8790A}.Release|Any CPU.Build.0 = Release|Any CPU
232258
EndGlobalSection
233259
GlobalSection(SolutionProperties) = preSolution
234260
HideSolutionNode = FALSE
@@ -266,6 +292,11 @@ Global
266292
{48DF1E40-93BA-436A-B460-5D1130316ADA} = {37D508B2-91E0-4B32-869B-DFF9E68EA213}
267293
{2F9D8932-2186-464F-BED6-7D7979C8FFA6} = {37D508B2-91E0-4B32-869B-DFF9E68EA213}
268294
{93D182B7-2F63-4661-BB32-94F1716CF03F} = {37D508B2-91E0-4B32-869B-DFF9E68EA213}
295+
{D31607D2-D689-488B-9F9F-92F47AC1D7F6} = {37D508B2-91E0-4B32-869B-DFF9E68EA213}
296+
{2448CE80-59AA-41B7-83A0-768BE5520F7A} = {D31607D2-D689-488B-9F9F-92F47AC1D7F6}
297+
{56416AD9-8E7B-4F72-B0E1-E75A024431F8} = {D31607D2-D689-488B-9F9F-92F47AC1D7F6}
298+
{8AFBB856-700A-4CCC-AE0E-9B622178E1E0} = {D31607D2-D689-488B-9F9F-92F47AC1D7F6}
299+
{0555B97D-E918-455B-951C-74EFCDA8790A} = {D31607D2-D689-488B-9F9F-92F47AC1D7F6}
269300
EndGlobalSection
270301
GlobalSection(ExtensibilityGlobals) = postSolution
271302
SolutionGuid = {D8E4FC26-5422-4C51-8BBC-D1AC0A578711}

package-tests.cake

+41-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class MockAssemblyExpectedResult : ExpectedResult
3535
StandardRunnerTests.Add(new PackageTest(
3636
1, "Net462Test",
3737
"Run mock-assembly.dll under .NET 4.6.2",
38-
"testdata/net462/mock-assembly.dll",
38+
"testdata/net462/mock-assembly.dll --trace:Debug",
3939
new MockAssemblyExpectedResult("net-4.6.2")));
4040

4141
AddToBothLists(new PackageTest(
@@ -142,6 +142,46 @@ StandardRunnerTests.Add(new PackageTest(
142142
"testdata/net462/mock-assembly.dll testdata/net6.0/mock-assembly.dll",
143143
new MockAssemblyExpectedResult("net-4.6.2", "netcore-6.0")));
144144

145+
//////////////////////////////////////////////////////////////////////
146+
// TEST OLDER VERSIONS OF NUNIT SWITCHING API IF NEEDED
147+
//////////////////////////////////////////////////////////////////////
148+
149+
StandardRunnerTests.Add(new PackageTest(
150+
1, "NUnit30Test",
151+
"Run a test under NUnit 3.0 using 2009 API",
152+
"testdata/NUnit3.0/net462/NUnit3.0.dll",
153+
new ExpectedResult("Passed")
154+
{
155+
Assemblies = new[] { new ExpectedAssemblyResult("NUnit3.0.dll", "net462") }
156+
}));
157+
158+
StandardRunnerTests.Add(new PackageTest(
159+
1, "NUnit301Test",
160+
"Run a test under NUnit 3.0.1 using 2009 API",
161+
"testdata/NUnit3.0.1/net462/NUnit3.0.1.dll",
162+
new ExpectedResult("Passed")
163+
{
164+
Assemblies = new[] { new ExpectedAssemblyResult("NUnit3.0.1.dll", "net462") }
165+
}));
166+
167+
StandardRunnerTests.Add(new PackageTest(
168+
1, "NUnit32Test",
169+
"Run a test under NUnit 3.2 using 20018 API",
170+
"testdata/NUnit3.2/net462/NUnit3.2.dll",
171+
new ExpectedResult("Passed")
172+
{
173+
Assemblies = new[] { new ExpectedAssemblyResult("NUnit3.2.dll", "net462") }
174+
}));
175+
176+
StandardRunnerTests.Add(new PackageTest(
177+
1, "NUnit310Test",
178+
"Run a test under NUnit 3.10 using 2018 API",
179+
"testdata/NUnit3.10/net462/NUnit3.10.dll",
180+
new ExpectedResult("Passed")
181+
{
182+
Assemblies = new[] { new ExpectedAssemblyResult("NUnit3.10.dll", "net462") }
183+
}));
184+
145185
//////////////////////////////////////////////////////////////////////
146186
// ASP.NETCORE TESTS
147187
//////////////////////////////////////////////////////////////////////

src/NUnitEngine/nunit.engine.api/Extensibility/IDriverFactory.cs

+4-2
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,19 @@ public interface IDriverFactory
2525
/// which the assembly is already known to reference.
2626
/// </summary>
2727
/// <param name="domain">The domain in which the assembly will be loaded</param>
28+
/// <param name="id">The driver id.</param>
2829
/// <param name="reference">An AssemblyName referring to the test framework.</param>
2930
/// <returns></returns>
30-
IFrameworkDriver GetDriver(AppDomain domain, AssemblyName reference);
31+
IFrameworkDriver GetDriver(AppDomain domain, string id, AssemblyName reference);
3132
#else
3233
/// <summary>
3334
/// Gets a driver for a given test assembly and a framework
3435
/// which the assembly is already known to reference.
3536
/// </summary>
37+
/// <param name="id">The driver id.</param>
3638
/// <param name="reference">An AssemblyName referring to the test framework.</param>
3739
/// <returns></returns>
38-
IFrameworkDriver GetDriver(AssemblyName reference);
40+
IFrameworkDriver GetDriver(string id, AssemblyName reference);
3941
#endif
4042
}
4143
}

src/NUnitEngine/nunit.engine.api/Extensibility/IFrameworkDriver.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public interface IFrameworkDriver
1818
/// Gets and sets the unique identifier for this driver,
1919
/// used to ensure that test ids are unique across drivers.
2020
/// </summary>
21-
string ID { get; set; }
21+
string ID { get; }
2222

2323
/// <summary>
2424
/// Loads the tests in an assembly.

src/NUnitEngine/nunit.engine.core.tests/Drivers/NUnit3FrameworkDriverTests.cs src/NUnitEngine/nunit.engine.core.tests/Drivers/NUnitFrameworkDriverTests.cs

+51-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Copyright (c) Charlie Poole, Rob Prouse and Contributors. MIT License - see LICENSE.txt
22

3-
#if NETFRAMEWORK
43
using System;
54
using System.Collections.Generic;
65
using System.Reflection;
@@ -13,22 +12,37 @@
1312
namespace NUnit.Engine.Drivers
1413
{
1514
// Functional tests of the NUnitFrameworkDriver calling into the framework.
16-
public class NUnit3FrameworkDriverTests
15+
#if NETFRAMEWORK
16+
[TestFixture("2009")]
17+
#endif
18+
[TestFixture("2018")]
19+
public class NUnitFrameworkDriverTests
1720
{
1821
private const string MOCK_ASSEMBLY = "mock-assembly.dll";
19-
private const string LOAD_MESSAGE = "Method called without calling Load first";
22+
private const string LOAD_MESSAGE = "Method called without calling Load first. Possible error in runner.";
2023

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

23-
private NUnit3FrameworkDriver _driver;
26+
private NUnitFrameworkDriver _driver;
2427
private string _mockAssemblyPath;
2528

29+
private string _whichApi;
30+
public NUnitFrameworkDriverTests(string whichApi)
31+
{
32+
_whichApi = whichApi;
33+
}
34+
2635
[SetUp]
2736
public void CreateDriver()
2837
{
29-
var assemblyName = typeof(NUnit.Framework.TestAttribute).Assembly.GetName();
38+
var nunitRef = typeof(TestAttribute).Assembly.GetName();
3039
_mockAssemblyPath = System.IO.Path.Combine(TestContext.CurrentContext.TestDirectory, MOCK_ASSEMBLY);
31-
_driver = new NUnit3FrameworkDriver(AppDomain.CurrentDomain, assemblyName);
40+
41+
#if NETFRAMEWORK
42+
_driver = new NUnitFrameworkDriver(AppDomain.CurrentDomain, _whichApi, "99", nunitRef);
43+
#else
44+
_driver = new NUnitFrameworkDriver("99", nunitRef);
45+
#endif
3246
}
3347

3448
[Test]
@@ -110,13 +124,41 @@ public void RunTestsAction_WithoutLoad_ThrowsInvalidOperationException()
110124
}
111125

112126
[Test]
113-
public void RunTestsAction_WithInvalidFilterElement_ThrowsNUnitEngineException()
127+
public void RunTestsAction_WithInvalidFilterElement_ThrowsException()
114128
{
115129
_driver.Load(_mockAssemblyPath, _settings);
116130

117131
var invalidFilter = "<filter><invalidElement>foo</invalidElement></filter>";
118132
var ex = Assert.Catch(() => _driver.Run(new NullListener(), invalidFilter));
119-
Assert.That(ex, Is.TypeOf<NUnitEngineException>());
133+
134+
if (_whichApi == "2018")
135+
{
136+
Assert.That(ex, Is.TypeOf<TargetInvocationException>());
137+
Assert.That(ex.InnerException, Is.TypeOf<ArgumentException>());
138+
}
139+
else
140+
Assert.That(ex, Is.TypeOf<NUnitEngineException>());
141+
}
142+
143+
#if NETFRAMEWORK
144+
// Nested Class tests Api Selection in the driver
145+
public class ApiSelectionTests()
146+
{
147+
[TestCase("4.2.2", "2018")]
148+
[TestCase("3.14.0", "2018")]
149+
[TestCase("3.2.0", "2018")]
150+
[TestCase("3.0.1", "2009")]
151+
[TestCase("3.0.0", "2009")]
152+
public void CorrectApiIsSelected(string nunitVersion, string apiVersion)
153+
{
154+
var driver = new NUnitFrameworkDriver(AppDomain.CurrentDomain, "99", new AssemblyName()
155+
{
156+
Name = "nunit.framework",
157+
Version = new Version(nunitVersion)
158+
});
159+
160+
Assert.That(driver.API, Is.EqualTo(apiVersion));
161+
}
120162
}
121163

122164
private class CallbackEventHandler : System.Web.UI.ICallbackEventHandler
@@ -133,6 +175,7 @@ public void RaiseCallbackEvent(string eventArgument)
133175
_result = eventArgument;
134176
}
135177
}
178+
#endif
136179

137180
public class NullListener : ITestEventListener
138181
{
@@ -143,4 +186,3 @@ public void OnTestEvent(string testEvent)
143186
}
144187
}
145188
}
146-
#endif

src/NUnitEngine/nunit.engine.core.tests/Drivers/NotRunnableFrameworkDriverTests.cs

+2-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ namespace NUnit.Engine.Drivers
1414
// Functional tests of the NUnitFrameworkDriver calling into the framework.
1515
public abstract class NotRunnableFrameworkDriverTests
1616
{
17-
private const string DRIVER_ID = "99";
1817
private const string EXPECTED_ID = "99-1";
1918

2019
protected string? _expectedRunState;
@@ -95,7 +94,6 @@ public void Run(string filePath, string expectedType)
9594
private IFrameworkDriver GetDriver(string filePath)
9695
{
9796
IFrameworkDriver driver = CreateDriver(filePath);
98-
driver.ID = DRIVER_ID;
9997
return driver;
10098
}
10199

@@ -126,7 +124,7 @@ public InvalidAssemblyFrameworkDriverTests()
126124

127125
protected override IFrameworkDriver CreateDriver(string filePath)
128126
{
129-
return new InvalidAssemblyFrameworkDriver(filePath, _expectedReason ?? "Not Specified");
127+
return new InvalidAssemblyFrameworkDriver(filePath, "99", _expectedReason ?? "Not Specified");
130128
}
131129
}
132130

@@ -142,7 +140,7 @@ public SkippedAssemblyFrameworkDriverTests()
142140

143141
protected override IFrameworkDriver CreateDriver(string filePath)
144142
{
145-
return new SkippedAssemblyFrameworkDriver(filePath);
143+
return new SkippedAssemblyFrameworkDriver(filePath, "99");
146144
}
147145
}
148146
}

src/NUnitEngine/nunit.engine.core.tests/DummyExtensions.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ namespace NUnit.Engine
1212
[Extension]
1313
public class DummyFrameworkDriverExtension : IDriverFactory
1414
{
15-
#if !NETFRAMEWORK
16-
public IFrameworkDriver GetDriver(AssemblyName reference)
15+
#if NETFRAMEWORK
16+
public IFrameworkDriver GetDriver(AppDomain domain, string id, AssemblyName reference)
1717
#else
18-
public IFrameworkDriver GetDriver(AppDomain domain, AssemblyName reference)
18+
public IFrameworkDriver GetDriver(string id, AssemblyName reference)
1919
#endif
2020
{
2121
throw new NotImplementedException();

src/NUnitEngine/nunit.engine.core.tests/Runners/TestAgentRunnerExceptionTests.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ public void Initialize()
2222
var driverService = Substitute.For<Drivers.IDriverService>();
2323
driverService.GetDriver(
2424
AppDomain.CurrentDomain,
25+
new TestPackage(),
26+
string.Empty,
2527
string.Empty,
26-
string.Empty,
2728
false).ReturnsForAnyArgs(_driver);
2829

2930
_runner = new FakeTestAgentRunner(new TestPackage("mock-assembly.dll").SubPackages[0])

src/NUnitEngine/nunit.engine.core.tests/Services/DriverServiceTests.cs

+9-20
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
using NUnit.Engine.Drivers;
88
using NUnit.Engine.Extensibility;
99

10-
namespace NUnit.Engine.Services.Tests
10+
namespace NUnit.Engine.Services
1111
{
1212
[TestFixture]
1313
public class DriverServiceTests
@@ -23,36 +23,25 @@ public void CreateDriverFactory()
2323
[TestCaseSource(nameof(DriverSelectionTestCases))]
2424
public void CorrectDriverIsUsed(string fileName, bool skipNonTestAssemblies, Type expectedType)
2525
{
26-
var driver = _driverService.GetDriver(AppDomain.CurrentDomain, Path.Combine(TestContext.CurrentContext.TestDirectory, fileName), null, skipNonTestAssemblies);
26+
var assemblyPath = Path.Combine(TestContext.CurrentContext.TestDirectory, fileName);
27+
var driver = _driverService.GetDriver(AppDomain.CurrentDomain, new TestPackage(assemblyPath), assemblyPath, null, skipNonTestAssemblies);
2728
Assert.That(driver, Is.InstanceOf(expectedType));
2829
}
2930

3031
static TestCaseData[] DriverSelectionTestCases = new[]
3132
{
32-
// TODO: make commented tests work
33-
#if NETFRAMEWORK
34-
new TestCaseData("mock-assembly.dll", false, typeof(NUnit3FrameworkDriver)),
35-
new TestCaseData("mock-assembly.dll", true, typeof(NUnit3FrameworkDriver)),
36-
//new TestCaseData("notest-assembly.dll", false, typeof(NUnit3FrameworkDriver)),
37-
#elif NET5_0_OR_GREATER
38-
new TestCaseData("mock-assembly.dll", false, typeof(NUnitNetCore31Driver)),
39-
new TestCaseData("mock-assembly.dll", true, typeof(NUnitNetCore31Driver)),
40-
//new TestCaseData("notest-assembly.dll", false, typeof(NUnitNetCore31Driver)),
41-
#else
42-
new TestCaseData("mock-assembly.dll", false, typeof(NUnitNetCore31Driver)),
43-
new TestCaseData("mock-assembly.dll", true, typeof(NUnitNetCore31Driver)),
44-
//new TestCaseData("notest-assembly.dll", false, typeof(NUnitNetCore31Driver)),
45-
#endif
46-
// Invalid cases should work with all target runtimes
33+
new TestCaseData("mock-assembly.dll", false, typeof(NUnitFrameworkDriver)),
34+
new TestCaseData("mock-assembly.dll", true, typeof(NUnitFrameworkDriver)),
35+
new TestCaseData("notest-assembly.dll", false, typeof(NUnitFrameworkDriver)).Ignore("Assembly not present"),
36+
new TestCaseData("notest-assembly.dll", true, typeof(SkippedAssemblyFrameworkDriver)).Ignore("Assembly not present"),
37+
38+
// Invalid cases should work with all target runtimes
4739
new TestCaseData("mock-assembly.pdb", false, typeof(InvalidAssemblyFrameworkDriver)),
4840
new TestCaseData("mock-assembly.pdb", true, typeof(InvalidAssemblyFrameworkDriver)),
4941
new TestCaseData("junk.dll", false, typeof(InvalidAssemblyFrameworkDriver)),
5042
new TestCaseData("junk.dll", true, typeof(InvalidAssemblyFrameworkDriver)),
5143
new TestCaseData("nunit.engine.core.dll", false, typeof(InvalidAssemblyFrameworkDriver)),
5244
new TestCaseData("nunit.engine.core.dll", true, typeof(SkippedAssemblyFrameworkDriver))
53-
//#if !NET5_0_OR_GREATER // Not yet working
54-
// new TestCaseData"notest-assembly.dll", true, typeof(SkippedAssemblyFrameworkDriver))
55-
//#endif
5645
};
5746

5847
[Test]

src/NUnitEngine/nunit.engine.core.tests/TestData.cs

-39
This file was deleted.

0 commit comments

Comments
 (0)