Comment 1 for bug 730891

Revision history for this message
Nicolas Rivera (nick4christ) wrote : Re: GUI runner option to stop upon failure

For anyone interested, I think I found a workaround. The following adding seems to do the trick:

   [NUnitAddin(Description = "Stop Upon Failure")]
   public class StopUponFailureAddIn : IAddin, EventListener
   {
      #region IAddin Members

      public bool Install(IExtensionHost host)
      {
         if (host == null)
            throw new ArgumentNullException("host");

         IExtensionPoint listeners = host.GetExtensionPoint("EventListeners");
         if (listeners == null)
            return false;

         listeners.Install(this);
         return true;
      }

      #endregion

      #region EventListener Members

      public void RunFinished(Exception exception)
      {
      }

      public void RunFinished(TestResult result)
      {
      }

      public void RunStarted(string name, int testCount)
      {
      }

      public void SuiteFinished(TestResult result)
      {
      }

      public void SuiteStarted(TestName testName)
      {
      }

      public void TestFinished(TestResult result)
      {
         if (result.IsError || result.IsFailure)
         {
            Trace.WriteLine("STOPPING TEST EXECUTION");
            Thread.Sleep(Timeout.Infinite);
         }
      }

      public void TestOutput(TestOutput testOutput)
      {
      }

      public void TestStarted(TestName testName)
      {
      }

      public void UnhandledException(Exception exception)
      {
      }

      #endregion
   }