I have in my project a lot of unit tests, written in JUnit and TestNG. The building process is based on maven with surefire plugin.
Is there any way/plugin for maven to
Try to use the junit Ant task with the timeout parameter.
http://ant.apache.org/manual/Tasks/junit.html
EDIT:
Another thing you can do is to use aspectj with someting like that:
public aspect TestTimeoutChecker {
long TIMEOUT = 60000;
pointcut invokeEvent() :
execution(@Test * *(..));
Object around() : invokeEvent() {
long start = System.currentTimeMillis();
Object object = proceed();
long took = System.currentTimeMillis() - start;
if (took > TIMEOUT) {
throw new RuntimeException("timeout! it took:" + took);
}
return object;
}
}