spock.lang
Annotation Type Timeout


@Retention(value=RUNTIME)
@Target(value={TYPE,METHOD})
public @interface Timeout

Indicates that the execution of a method should time out after the given duration has elapsed. The default time unit is seconds.

Timeouts can be applied to feature methods, fixture methods, and spec classes. When applied to a feature method, the timeout is per execution of one iteration, and does not include time spent in fixture methods. When applied to a fixture method, the timeout is per execution of the fixture method. Applying the timeout to a spec class has the same effect as applying it to each feature (but not fixture) method that isn't already annotated with Timeout.

Timed methods are invoked on the regular test framework thread. This can be important for integration tests that hold thread-local state. When a method times out, it will be interrupted repeatedly until it (hopefully) returns. Methods that continue to ignore interruption may run forever.

When a timeout is reported to the user, the stack trace shown reflects the execution stack of the test framework thread when the timeout was reached.


Required Element Summary
 int value
          The duration after which the execution of the annotated feature or fixture method times out.
 
Optional Element Summary
 TimeUnit unit
          The duration's time unit
 

Element Detail

value

public abstract int value
The duration after which the execution of the annotated feature or fixture method times out.

Returns:
the duration after which the execution of the annotated feature or fixture method times out

unit

public abstract TimeUnit unit
The duration's time unit

Returns:
the duration's time unit
Default:
java.util.concurrent.TimeUnit.SECONDS