简体   繁体   中英

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.

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.

If the Suite level turns out to be the wrong approach (ie "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)

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.

您可以使用“@Test(timeout =)”搜索并替换“@Test”。应该可以找到锁定的测试并在此之后撤消。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM