← Back to team overview

nunit-core team mailing list archive

[Bug 812697] Re: Stopping an running test case using "Stop" button in NUnit GUI

 

NUnit stops the tests by the simple expedient of aborting the thread
that runs the tests. The problem you are encountering is in the logic of
the .NET Thread.Abort call.

Thread.Abort, when issued against a managed thread, normally raises a
System.Threading.ThreadAbortException. There are several exceptions to
this, however, where the exception is not raised immediately.

One of these cases is a thread that is executing unmanaged code. The
ThreadState is set to AbortRequested and the exception is not thrown
until the flow of control returns to managed code. That's why your
combined managed/unmanaged example works.

There is really nothing NUnit can do about this so long as we are using
Thread.Abort. In a future release, we plan to include a cooperative
cancel design, allowing long-running code to periodically check a flag
to discover whether it should stop running. But even in this case, there
is no way we can guarantee cancellation of code that doesn't cooperate.

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

Title:
  Stopping an running test case using "Stop" button in NUnit GUI

Status in NUnit V2 Test Framework:
  Won't Fix

Bug description:
  I am facing a strange trouble in stopping a running test case using
  the NUnit GUI.

  My setup involves "MANAGED .NET CLR/C++" code interacting with "NATIVE
  WIN32/C++" code.

  If i STOP a NATIVE WIN32 test case, NUNIT does not seem to end the
  test case.
  On the contrary, the test case keeps on running in the background.

  I have tried to explain it graphically in
  https://bitbucket.org/purnank/teststoppingnunit/raw/d3fca2b8b85a/StoppingNunit/docs/StopRunningTestCase.doc

  To reproduce this, i have also shared a minimal sample application.
  You can download the code from https://bitbucket.org/purnank/teststoppingnunit

  Version of NUnit used: 2.5.10.11092

  (As discussed in http://groups.google.com/group/nunit-
  discuss/browse_thread/thread/76b2f92ae6404ad4)

To manage notifications about this bug go to:
https://bugs.launchpad.net/nunitv2/+bug/812697/+subscriptions


References