NUnit throws NullReferenceException when return null from ISuiteBuilder.BuildFrom(Type) method

Bug #600555 reported by W van Gool
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
NUnit V2
Fix Released
Medium
Charlie Poole

Bug Description

Version: 2.5.5, GUI Runner

On the NUnit-site the documentation regarding the ISuiteBuilder-
interface is as follows (http://www.nunit.org/index.php?p=suiteBuilders&r=2.5.5):

"CanBuildFrom should return true if the specified Type is one from
which the builder is able to create a fixture. This usually involve
examining the Type and its attributes.

The BuildFrom method should return a test fixture completely populated
with its contained test cases. Return null if it is not possible to
build a fixture using the provided Type."

However, when a custom implementation of the ISuiteBuilder-interface returns NULL after calling the BuildFrom(Type)-method, a NullReferenceException is thrown:

System.NullReferenceException...
Server stack trace:
   at NUnit.Core.NamespaceTreeBuilder.Add(TestSuite fixture)
   at NUnit.Core.NamespaceTreeBuilder.Add(IList fixtures)
   at NUnit.Core.Builders.TestAssemblyBuilder.BuildTestAssembly(String
assemblyName, IList fixtures, Boolean autoSuites)
   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(I ntPtr
md, Object[] args, Object server, Int32 methodPtr, Boolean
fExecuteInContext, Object[]& outArgs)
   at
System.Runtime.Remoting.Messaging.StackBuilderSink.PrivateProcessMessage(Ru ntimeMethodHandle
md, Object[] args, Object server, Int32 methodPtr, Boolean
fExecuteInContext, Object[]& outArgs)
   at
System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMess age
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)

The problem could be solved by either updating the documentation by not allowing a NULL-value to be returned (recommended), or by accepting null-values and not crashing.

Related branches

Changed in nunitv2:
status: New → Triaged
importance: Undecided → Medium
Changed in nunitv2:
assignee: nobody → Charlie Poole (charlie.poole)
milestone: none → 2.5.6
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  Edit
Everyone can see this information.

Other bug subscribers