Spock version: 2.0-groovy-3.0-SNAPSHOT
Problem: need a tool to repeat certain test _regardless_ of the outcome
Junit5 equivalent: @RepeatedTest
I used to have a simple custom 'Rerun' extension for this purpose, but it no longer works in spock 2.0.
my extension for spock 1.3: RerunExtension
error I receive in spock 2.0:
java.util.NoSuchElementException
at java.util.LinkedList.removeFirst(LinkedList.java:270)
at org.spockframework.mock.runtime.MockController.leaveScope(MockController.java:76)
which is thrown right after the end of the second run (first repeated run).
Looking at available @Retry, I don't think it's possible to achieve with current implementation since it only retries on throwable thrown.
I unfortunately wasn't able to track down the issue or come up with a workaround, so any help/hint will be greatly appreciated.
Do you need this for also for data-driven tests? Otherwise it would be just where: run << (1..10)
And even for data-driven with multi variable data pipes:
where:
[[param1, param2], run] << [[
['a', 'b'],
['c', 'd']
], (1..5)].combinations()
You could adapt the code from @Retry for the time being, but be aware, that it doesn't generate new UniqueIds on re-execution, and while you can now change the DisplayName properly you might run into complications.
To support this properly, might take some time.
BTW you can't combine @ParameterizedTest with @RepeatedTest on JUnit Jupiter either.
That should do the trick, thx
Most helpful comment
Do you need this for also for data-driven tests? Otherwise it would be just
where: run << (1..10)And even for data-driven with multi variable data pipes:
You could adapt the code from
@Retryfor the time being, but be aware, that it doesn't generate newUniqueIdson re-execution, and while you can now change theDisplayNameproperly you might run into complications.To support this properly, might take some time.
BTW you can't combine
@ParameterizedTestwith@RepeatedTeston JUnit Jupiter either.