Package spock.lang
Annotation Type Retry
-
@Beta @Retention(RUNTIME) @Target({TYPE,METHOD}) public @interface Retry
Retries the given feature if an exception occurs during execution.Retries can be applied to feature methods and spec classes. Applying it to a spec class has the same effect as applying it to each feature method that isn't already annotated with
@Retry
.A
@Retry
annotation that is declared on a spec class is applied to all features in all subclasses as well, unless a subclass declares its own annotation. If so, the retries defined in the subclass are applied to all feature methods declared in the subclass as well as inherited ones.- Since:
- 1.2
-
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description Class<? extends Closure>
condition
Condition that is evaluated to decide whether the feature should be retried.int
count
The number of retries.int
delay
Delay between retries in millis, 0 to disable.Class<? extends Throwable>[]
exceptions
Configures which types of Exceptions should be retried.Retry.Mode
mode
Retry mode, controls what is retried.
-
-
-
-
condition
Class<? extends Closure> condition
Condition that is evaluated to decide whether the feature should be retried. The configured closure is called with a delegate of typeRetryConditionContext
which provides access to the current exception andSpecification
instance. The feature is retried if the exception class passes the type check and the specified condition holds true. If no condition is specified, only the type check is performed.- Returns:
- predicate that must hold for the feature to be retried.
- Default:
- groovy.lang.Closure.class
-
-
-
mode
Retry.Mode mode
Retry mode, controls what is retried.- Returns:
- retry mode
- Default:
- spock.lang.Retry.Mode.ITERATION
-
-