Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Timing out tests in TestNG

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.

like image 903
sblundy Avatar asked Dec 08 '08 21:12

sblundy


2 Answers

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.

like image 124
Ruben Avatar answered Sep 18 '22 01:09

Ruben


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)

like image 30
VonC Avatar answered Sep 18 '22 01:09

VonC