I would like to stop and mark as failed too long running junit tests (executed within Maven 3 build). I am aware of three ways of doing it:
1) Using Test annotation with timeout parameter:
@Test(timeout=100)
public void testWithTimeout() {
...
}
2) Using Rule annotation:
@Rule
public Timeout globalTimeout = new Timeout(100);
3) Configuring maven-surefire-plugin using following options:
forkedProcessTimeoutInSeconds=1
reuseForks=false
The clue is 1) and 2) requires to change each test (it hurts when you have many thousands). 3) solution is not acceptable as within many modules first test starts the context which is used by the test - tests performance would drastically decrease.
Do you have any other ideas how to achieve that? Any tricky solution (not involving patching JUnit :))?