Menu

#2 Abstract tests result in a null reference exception

open
nobody
None
5
2014-08-18
2009-08-31
Mike Jones
No

I need to be able to do this using csUnit (the code is the same):

http://weblogs.asp.net/nunitaddin/archive/2004/05/18/134151.aspx

A base test is written with an abstract factory method which is implemented in a subclass to return an implementation of the interface which the base test verifies. It is essential for writing contract tests for interfaces.

Two issues:

1) If the namespace containing the abstract test is executed, the test runner throws a null reference exception (see below):

System.NullReferenceException was unhandled
Message="Object reference not set to an instance of an object."
Source="mscorlib"
StackTrace:
Server stack trace:
at System.Windows.Forms.Control.MarshaledInvoke(Control caller, Delegate method, Object[] args, Boolean synchronous)
at System.Windows.Forms.Control.Invoke(Delegate method, Object[] args)
at csUnit.Ui.Controls.TabPages.TestHierarchyControl.OnTestPassed(Object sender, TestResultEventArgs args)
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.AsyncProcessMessage(IMessage msg, IMessageSink replySink)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.EndInvokeHelper(Message reqMsg, Boolean bProxyCase)
at System.Runtime.Remoting.Proxies.RemotingProxy.Invoke(Object NotUsed, MessageData& msgData)
at csUnit.Interfaces.TestEventHandler.EndInvoke(IAsyncResult result)
at csUnit.Core.Loader.TestEventSink.TestEventHandlerAsyncCallback(IAsyncResult ar)
at System.Runtime.Remoting.Messaging.AsyncResult.SyncProcessMessage(IMessage msg)
at System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(IMessage msg, IMessageSink replySink)
at System.Runtime.Remoting.Proxies.AgileAsyncWorkerItem.DoAsyncCall()
at System.Runtime.Remoting.Proxies.AgileAsyncWorkerItem.ThreadPoolCallBack(Object o)
at System.Threading._ThreadPoolWaitCallback.WaitCallback_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallbackInternal(_ThreadPoolWaitCallback tpWaitCallBack)
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback(Object state)
InnerException:

2) The results are not reported on the csUnit GUI when only the subclass implementation of the test is executed, through the subclassed test itself seems runs properly, as I am able to step through it with the debugger.

While no exception is thrown when the Ignore attribute is placed on the base class, it will prevent the subclass from being executed, as it is inherited.

I'm willing to help find a solution.

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.