views:

122

answers:

1

We have a bunch of tests in a maven2 project and build with cruisecontrol. However the build regularly hangs, because the annotation of the test with a timeout

@Test(timeout = 5000)

is ignored. I tried and run maven locally, reproducing the fact that the timeout is ignored.

Is there a way to activate the timeout for the tests again?

I currently use a workaround in setting a timeout in cruisecontrol. However this simply means that the whole build is canceled, and not just the tests that should fail.

Remark: It seems in maven 1 there was a property to activate the junit timeout which is missing in maven 2.

+1  A: 

Try to set the forkedProcessTimeoutInSeconds parameter of the Maven Surefire Plugin:

Kill the forked test process after a certain number of seconds. If set to 0, wait forever for the process, never timing out

This seems to be an equivalent of the maven.junit.timeout test property in Maven 1 and will "activate" a timeout at the Maven level (different from the annotation).

Pascal Thivent
Thanks for the input. Any ideas why the annotation isn't working?
roesslerj
@roesslerj I'm not aware of all the details and I'm going to state the obvious but I guess the surefire plugin doesn't implement support for this. You can always try to raise an issue http://jira.codehaus.org/browse/SUREFIRE.
Pascal Thivent