← Back to team overview

nunit-core team mailing list archive

[Bug 611938] [NEW] Generic Test Instances disappear

 

Public bug reported:

NUnit 2.5.6 ignores all instances but one of a generic test fixture that uses a default constructor and has only Type args given
on its TestFixtureAttribute. This is a serious bug since tests simply do not appear and are not run.

For example, this fixture will only be instantiated once - using either
the first or the last attribute depending on the runtime.

[TestFixture(typeof(int)]
[TestFixture(typeof(long)]
[TestFixture(typeof(short)]
public class GenericFixture<T> { }

As a workaround, add a single argument to the fixture and all three
instances will be created.

[TestFixture(typeof(int), 42]
[TestFixture(typeof(long), 42]
[TestFixture(typeof(short), 42]
public class GenericFixture<T> 
{
   public GenericFixture(int theAnswer) { } 
}

Use of an argument forces the code into a different path that doesn't
have the bug.

** Affects: nunit-3.0
     Importance: High
     Assignee: Charlie Poole (charlie.poole)
         Status: Triaged

** Affects: nunitv2
     Importance: High
     Assignee: Charlie Poole (charlie.poole)
         Status: Triaged

** Changed in: nunitv2
       Status: New => Triaged

** Changed in: nunitv2
   Importance: Undecided => High

** Changed in: nunitv2
     Assignee: (unassigned) => Charlie Poole (charlie.poole)

** Also affects: nunit-3.0
   Importance: Undecided
       Status: New

** Changed in: nunit-3.0
       Status: New => Triaged

** Changed in: nunit-3.0
   Importance: Undecided => High

** Changed in: nunit-3.0
     Assignee: (unassigned) => Charlie Poole (charlie.poole)

-- 
Generic Test Instances disappear
https://bugs.launchpad.net/bugs/611938
You received this bug notification because you are a member of NUnit
Developers, which is subscribed to NUnit V2.

Status in NUnit Test Framework: Triaged
Status in NUnit V2 Test Framework: Triaged

Bug description:
NUnit 2.5.6 ignores all instances but one of a generic test fixture that uses a default constructor and has only Type args given
on its TestFixtureAttribute. This is a serious bug since tests simply do not appear and are not run.

For example, this fixture will only be instantiated once - using either the first or the last attribute depending on the runtime.

[TestFixture(typeof(int)]
[TestFixture(typeof(long)]
[TestFixture(typeof(short)]
public class GenericFixture<T> { }

As a workaround, add a single argument to the fixture and all three instances will be created.

[TestFixture(typeof(int), 42]
[TestFixture(typeof(long), 42]
[TestFixture(typeof(short), 42]
public class GenericFixture<T> 
{
   public GenericFixture(int theAnswer) { } 
}

Use of an argument forces the code into a different path that doesn't have the bug.





Follow ups

References