@@ -263,59 +263,21 @@ It also provides special support for data driven features, offering to either re
263263
264264[source,groovy]
265265----
266- class FlakyIntegrationSpec extends Specification {
267- @Retry
268- def retry3Times() { ... }
269-
270- @Retry(count = 5)
271- def retry5Times() { ... }
272-
273- @Retry(exceptions=[IOException])
274- def onlyRetryIOException() { ... }
275-
276- @Retry(condition = { failure.message.contains('foo') })
277- def onlyRetryIfConditionOnFailureHolds() { ... }
278-
279- @Retry(condition = { instance.field != null })
280- def onlyRetryIfConditionOnInstanceHolds() { ... }
281-
282- @Retry
283- def retryFailingIterations() {
284- ...
285- where:
286- data << sql.select()
287- }
288-
289- @Retry(mode = Retry.Mode.FEATURE)
290- def retryWholeFeature() {
291- ...
292- where:
293- data << sql.select()
294- }
295-
296- @Retry(delay = 1000)
297- def retryAfter1000MsDelay() { ... }
298- }
266+ include::{sourcedir}/extension/RetryDocSpec.groovy[tag=example-common]
267+ include::{sourcedir}/extension/RetryDocSpec.groovy[tag=example-a]
299268----
300269
301270Retries can also be applied to spec classes which has the same effect as applying it to each feature method that isn't
302- already annotated with {@code Retry} .
271+ already annotated with ` Retry` .
303272
304273[source,groovy]
305274----
306- @Retry
307- class FlakyIntegrationSpec extends Specification {
308- def "will be retried with config from class"() {
309- ...
310- }
311- @Retry(count = 5)
312- def "will be retried using its own config"() {
313- ...
314- }
315- }
275+ include::{sourcedir}/extension/RetryDocSpec.groovy[tag=example-b1]
276+ include::{sourcedir}/extension/RetryDocSpec.groovy[tag=example-common]
277+ include::{sourcedir}/extension/RetryDocSpec.groovy[tag=example-b2]
316278----
317279
318- A {@code @ Retry} annotation that is declared on a spec class is applied to all features in all subclasses as well,
280+ A `@ Retry` annotation that is declared on a spec class is applied to all features in all subclasses as well,
319281unless a subclass declares its own annotation. If so, the retries defined in the subclass are applied to all feature
320282methods declared in the subclass as well as inherited ones.
321283
@@ -324,25 +286,15 @@ Running `BarIntegrationSpec` will execute `inherited` and `bar` with two retries
324286
325287[source,groovy]
326288----
327- @Retry(count = 1)
328- abstract class AbstractIntegrationSpec extends Specification {
329- def inherited() {
330- ...
331- }
332- }
289+ include::{sourcedir}/extension/RetryDocSpec.groovy[tag=example-c]
290+ ----
333291
334- class FooIntegrationSpec extends AbstractIntegrationSpec {
335- def foo() {
336- ...
337- }
338- }
292+ If multiple `@Retry` annotations are present, they can be used to have different retry settings
293+ for different situations:
339294
340- @Retry(count = 2)
341- class BarIntegrationSpec extends AbstractIntegrationSpec {
342- def bar() {
343- ...
344- }
345- }
295+ [source,groovy,indent=0]
296+ ----
297+ include::{sourcedir}/extension/RetryDocSpec.groovy[tag=example-d]
346298----
347299
348300Check https://github.com/spockframework/spock/blob/master/spock-specs/src/test/groovy/org/spockframework/smoke/extension/RetryFeatureExtensionSpec.groovy[RetryFeatureExtensionSpec] for more examples.
0 commit comments