views:

295

answers:

4

Thanks to a library upgrade (easymock 2.2 -> 2.4), we're having tests that have started locking up. I'd like to have a time out on individual tests, all of them. The idea is to identify the locked up tests - we're currently guessing - and fix them.

Is this possible, preferably on a suite-wide level? We have 400 tests, doing this each method or even each class will be time consuming.

+4  A: 

The suite tag can have the time-out attribute. This time-out will be used as default for all test methods.

This default time-out can than be overridden on a per test method basis.

Ruben
We're using maven, so I had to find the relevant settings on the surefire plugin. Unfortunately, it's not telling us which test is dieing on?! Oh well, that'll be another question.
sblundy
+1  A: 

If the Suite level turns out to be the wrong approach (i.e. "too wide a net", because you end up marking too much methods with a timeout limit), you need to define a custom IAnnotationTransformer which, for each illegible function, will give you the opportunity to modify a @Test annotation (with, for instance the setTimout() method).
(setTimout(0) cancels a timeout directive)

VonC
A: 

You can do a search and replace for "@Test" with "@Test(timeout=)" Should work to find the locked up test and can be undone after that.

Jorn
A: 

Very late, but: running jstack -l <PID> will give you the stack dump, which you can inspect to find which calls are stuck. You might want to sample a few times to be sure they're stuck.

LarryW