Skip to content

Commit

Permalink
Implement support for NUnit 3.8.0, 3.8.1, 3.9.0. Fixes #4.
Browse files Browse the repository at this point in the history
The issue causing one of the tests to fail was that the root test is always a TestAssembly as of NUnit 3.8.0, with the SetupFixture being the only test.
  • Loading branch information
Sebazzz committed Jan 3, 2018
1 parent be67099 commit 25da6b8
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
4 changes: 2 additions & 2 deletions nuget/NUnitTestOrdering.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<projectUrl>https://github.com/Sebazzz/NUnitTestOrdering</projectUrl>
<iconUrl>https://raw.githubusercontent.com/Sebazzz/NUnitTestOrdering/master/nuget/NUnitTestOrdering.png</iconUrl>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
<description>Allows you to hierarchically order your entire (or part of) your NUnit test suite.</description>
<description>Allows you to hierarchically order your entire (or part of) your NUnit test suite, support dependencies between tests and skipping tests if their dependencies fail. Ideal for complex integration tests.</description>
<tags>NUnit Order</tags>
<releaseNotes>
<![CDATA[Version 1.0:
Expand All @@ -20,7 +20,7 @@

<dependencies>
<!-- Since we rely on some details on how NUnit functions, lets keep it limited to minor versions. -->
<dependency id="NUnit" version="[3.7, 3.8)" />
<dependency id="NUnit" version="[3.7, 3.10)" />
</dependencies>
</metadata>
<files>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NUnit" version="3.7.1"/>
<package id="NUnit" version="3.7.0"/>
<package id="NUnit" version="3.7.0"/>
<package id="NUnit" version="3.7.1"/>
<package id="NUnit" version="3.8.0"/>
<package id="NUnit" version="3.8.1"/>
<package id="NUnit" version="3.9.0"/>

<!-- To be sure, though in the future we
might consider testing with different console
Expand Down
6 changes: 4 additions & 2 deletions src/NUnitTestOrdering/EnableTestOrderingAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ public void ApplyToTest(Test test) {
// but the parent of the SetUpFixture is null. This means we really aren't
// able to determine the test assembly, except to assume that the SetUpFixture's type is in the test assembly
TestSuite root = testAssembly;
if (testAssembly == null) {
SetUpFixture setUpFixture = test as SetUpFixture;
if (testAssembly == null || testAssembly.Tests.Count == 1 && testAssembly.Tests[0] is SetUpFixture) {
// As of NUnit 3.8.0 the SetupFixture is not the root but the first and only test of the TestAssembly

SetUpFixture setUpFixture = testAssembly == null ? test as SetUpFixture : (SetUpFixture) testAssembly.Tests[0];

if (setUpFixture == null) {
throw new TestOrderingException($"Expected condition: input object {test} is not a {typeof(TestAssembly).FullName} nor a {typeof(SetUpFixture).FullName}");
Expand Down
2 changes: 1 addition & 1 deletion src/NUnitTestOrdering/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@

[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0.0-alpha5")]
[assembly: AssemblyInformationalVersion("1.0.0.0-beta1")]

[assembly: InternalsVisibleTo("NUnitTestOrdering.Tests")]

0 comments on commit 25da6b8

Please sign in to comment.