After exiting for timeout the teardown method is not executed

Bug #904841 reported by Charlie Poole
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
NUnit Framework
Fix Released
High
Charlie Poole
NUnit V2
Fix Released
Medium
Charlie Poole

Bug Description

From the NUnit-discuss list: http://groups.google.com/group/nunit-discuss/browse_thread/thread/9db7ebfc1114b91a

When a test times out, the teardown method is not executed. The person reporting it wants the TearDown to execute so that cleanup may be performed. This will need some investigation both for general desirability and feasibility.

Tags: feature

Related branches

Revision history for this message
Charlie Poole (charlie.poole) wrote :

I have verified that teardown is executed after a timeout. There was no test for this case, so I added one.

If your own teardown is not being executed at all, it may be that the setup is hanging and causing the timeout. If setup does not complete, then teardown is not run.

Changed in nunitv2:
status: New → Invalid
Revision history for this message
Charlie Poole (charlie.poole) wrote :

I'm reactivating this. On rerunning the test I see that the problem does in fact exist.

Changed in nunitv2:
status: Invalid → Confirmed
Revision history for this message
Charlie Poole (charlie.poole) wrote :

This turned out to be a race condition between the main test thread and the individual test case thread. In some cases the teardown was run, in others not at all and in still others teardown could start and then be interupted. Inserting a Join in the logic that cancels the thread causes it to work reliably.

The down side of this fix is that any test thread that absolutely refuses to terminate - e.g. by using an infinite loop in the ThreadAbortException handler - will hang up NUnit itself. We'll wait to see if this is a practical problem in the future.

Changed in nunitv2:
importance: Undecided → Medium
assignee: nobody → Charlie Poole (charlie.poole)
milestone: none → 2.6.0
status: Confirmed → Fix Committed
Changed in nunit-3.0:
status: New → Triaged
importance: Undecided → High
assignee: nobody → Charlie Poole (charlie.poole)
milestone: none → 2.9.6
Changed in nunit-3.0:
status: Triaged → Fix Committed
Changed in nunitv2:
status: Fix Committed → Fix Released
Changed in nunit-3.0:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.