← Back to team overview

nunit-core team mailing list archive

[Bug 577156] Re: SimpleTestRunner miss handles point of exception

 

I removed this from the 2.9.6 milestone since it's not clear whether
custom EventListeners will be used in NUnit 3.0. We may end up providing
this functionality without use of addins, in which case the problem will
be resolved in a different way.

** Changed in: nunit-3.0
    Milestone: 2.9.6 => None

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

Title:
  SimpleTestRunner miss handles point of exception

Status in NUnit Test Framework:
  Triaged
Status in NUnit V2 Test Framework:
  Won't Fix

Bug description:
  The SimpleTestRunner performs a  an odd skip of Exception processing
  when faced with a fully un-implemented EventListener.  What happens is
  that my RunStarted throws an Exception and this gets caught end then
  RunFinished is called which then throws an exception -- the stack
  trace makes it look like the RunFinished was the culprit when in fact
  the RunStart began the exceptional behavior.  This occurs mainly
  because the catch( Exception exception ) catches everything.  Perhaps
  what it should do is catch NUnit exceptions and throw all other
  exceptions -- I'm not familiar enough with the architecture around
  Exception testing, Assert Exceptions, etc.

  So here is the culprit code in SimpleTestRunner, Line 141, of release
  2.5.5.101112.

  public virtual TestResult Run( EventListener listener, ITestFilter filter )
  {
  	try
  	{
          log.Debug("Starting test run");

  		// Take note of the fact that we are running
  		this.runThread = Thread.CurrentThread;

  		listener.RunStarted( this.Test.TestName.FullName, test.CountTestCases( filter ) );
  		
  		testResult = test.Run( listener, filter );

  		// Signal that we are done
  		listener.RunFinished( testResult );
          log.Debug("Test run complete");

  		// Return result array
  		return testResult;
  	}
  	catch( Exception exception )
  	{
                  // RunStart actually threw the exception. so RunFinish doesn't make sense.

                  // RunFinish then throws an exception when really the first exception should be handled first.
  		// Signal that we finished with an exception
  		listener.RunFinished( exception );
  		// Rethrow - should we do this?
  		throw;
  	}
  	finally
  	{
  		runThread = null;
  	}
  }

  Cheers,
  L-

To manage notifications about this bug go to:
https://bugs.launchpad.net/nunit-3.0/+bug/577156/+subscriptions


References