Comment 6 for bug 730891

Revision history for this message
Charlie Poole (charlie.poole) wrote : Re: [Bug 730891] Re: GUI runner option to stop upon failure

Hi Nicolas,

On Mon, Jul 25, 2011 at 6:47 PM, Nicolas Rivera
<email address hidden> wrote:
> There is a more flexible way to do this that I just found out about.
>
> In TearDown() one could write:
>
> if (TestContext.CurrentContext.Result.Status == TestStatus.Failed)
>  { Thread.Sleep(Timeout.Infinite); }

The main problem here is that "Sleep" is not the same as "Stop." It's
more like you're hanging the Gui. As a result, the test run never ends
and NUnit never does any of the stuff it does at the end of a test run
like saving the XML output.

> The problems with that approach are:
>
> 1. The error call stack does not get printed in the "Error and Failures" tab (which makes sense, since TearDown() has not completed).  Ideally the CurrentContext would include the exception also, so that the call stack could be output to the "Text Output" tab.

Yup... because that test never ended either.

> 2. Thread.Sleep(Timeout.Infinite) does not allow the GUI to close cleanly, so the process has to be killed through task manager.  Ideally there would be a way to tell any NUnit client (whether GUI or console) to stop running a batch of tests from inside teardown.

Yup... again, as above.

>
> Could the above two changes be considered instead of my original feature
> request?  I rather like those than a GUI-centric feature.  Plust they
> allow for a higher control and granularity than a simple global GUI
> setting to "Stop Upon Failure".

I'm not 100% sure what you are asking for. If it's to have "Sleep" work as
a "Stop" that's not possible. If it's to expose some way for a test to
individually
request that no further tests should be run, it's technically doable in a few
different ways. All the approaches probably involve a special exception
being thrown. That could be through an Assert or a method call to
the TestContext. Throwing an exception allows the test to complete
correctly before stopping the Gui. Stopping it would require completion
of all the teardowns from the test itself up to the top of the tree as well
as any relevant After actions, so it's non-trivial (but I think doable).

Whether we want to do this at all is what I'm wondering about. I'll
start a discussion on the mailing list about that question.

Charlie

> Are TextContexts something carried over to NUnit 3.0?
>
> --
> You received this bug notification because you are subscribed to NUnit
> Framework.
> https://bugs.launchpad.net/bugs/730891
>
> Title:
>  GUI runner option to stop upon failure
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/nunit-3.0/+bug/730891/+subscriptions
>