[Mono-list] NUnit does not detect Fail() in other threads?
Tue, 29 Oct 2002 12:34:52 +0100
Is it just me or does NUnit fail to
detect assertion failures in other
threads? Running the below test,
NUnit reports no errors. I think
it's not a problem with the test
itself, but correct me if it is.
This behavior would agree with what
I understand from the NUnit sources:
an assertion is handled as an exception
and caught at the top, so from other threads
the exception disappears "ins Blaue hinein".
This was reported about a month ago
(bug 618502), but no reaction yet.
Could require major changes to NUnit's
As far as I can tell from the API docs,
there is no way to catch that exception
when the child exits. Suggested workaround
is to put e.g. "thread_reached_end = true"
just before the child's regular return
statement and assert that in the parent
public class FoobarTest
private static bool thread_entered;
private static void otherthread()
thread_entered = true;
Assertion.Fail("This should fail, but does not.");
public void Test1()
thread_entered = false;
ts = new ThreadStart(otherthread);
t = new Thread(ts);
Assertion.AssertEquals("thread should have been entered", thread_entered,
Je kan ook Messenger berichten op je mobiele telefoon ontvangen!