Using Open Generic Types In TestFixture Attribute Causes Exception When Loading Test DLL

Bug #1025218 reported by MrKWatkins
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
NUnit V2
Fix Released
Medium
Charlie Poole

Bug Description

The following C# test fixture: (built for .NET 3.5 under VS2010 SP1)

[TestFixture(typeof(List<>))]
public sealed class NUnitBug<T>
{
    [Test]
    public void Test()
    {
    }
}

Causes the following exception when loading the tests in the NUnit GUI runner:

System.NullReferenceException...

Server stack trace:
   at NUnit.Core.TypeHelper.GetDisplayName(Type type)
   at NUnit.Core.TypeHelper.GetDisplayName(Type type, Object[] arglist)
   at NUnit.Core.TestSuite..ctor(Type fixtureType, Object[] arguments)
   at NUnit.Core.NUnitTestFixture..ctor(Type fixtureType, Object[] arguments)
   at NUnit.Core.Builders.NUnitTestFixtureBuilder.BuildSingleFixture(Type type, Attribute attr)
   at NUnit.Core.Builders.NUnitTestFixtureBuilder.BuildMultipleFixtures(Type type, Attribute[] attrs)
   at NUnit.Core.Builders.NUnitTestFixtureBuilder.BuildFrom(Type type)
   at NUnit.Core.Extensibility.SuiteBuilderCollection.BuildFrom(Type type)
   at NUnit.Core.TestFixtureBuilder.BuildFrom(Type type)
   at NUnit.Core.Builders.TestAssemblyBuilder.GetFixtures(Assembly assembly, String ns)
   at NUnit.Core.Builders.TestAssemblyBuilder.Build(String assemblyName, Boolean autoSuites)
   at NUnit.Core.Builders.TestAssemblyBuilder.Build(String assemblyName, String testName, Boolean autoSuites)
   at NUnit.Core.TestSuiteBuilder.BuildSingleAssembly(TestPackage package)
   at NUnit.Core.TestSuiteBuilder.Build(TestPackage package)
   at NUnit.Core.SimpleTestRunner.Load(TestPackage package)
   at NUnit.Core.ProxyTestRunner.Load(TestPackage package)
   at NUnit.Core.ProxyTestRunner.Load(TestPackage package)
   at NUnit.Core.RemoteTestRunner.Load(TestPackage package)
   at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
   at System.Runtime.Remoting.Messaging.StackBuilderSink.PrivateProcessMessage(RuntimeMethodHandle md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
   at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext)

Exception rethrown at [0]:
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at NUnit.Core.TestRunner.Load(TestPackage package)
   at NUnit.Util.TestDomain.Load(TestPackage package)
   at NUnit.Util.TestLoader.LoadTest(String testName)

Tested in NUnit 2.5.10 and 2.6.0 GUI runners and under ReSharper 6.1.

Related branches

Revision history for this message
Charlie Poole (charlie.poole) wrote :

Of course, this can't work, but NUnit should give an error message rather than failing.

Changed in nunitv2:
status: New → Triaged
importance: Undecided → Medium
Changed in nunitv2:
assignee: nobody → Charlie Poole (charlie.poole)
milestone: none → 2.6.1rc2
Revision history for this message
Charlie Poole (charlie.poole) wrote :

Fixed now so it gives an error message when attempting to instantiate a test fixture with an open Type.

Changed in nunitv2:
status: Triaged → Fix Committed
Changed in nunitv2:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.