Determine order of execution of Spock tests
12,371
You can use @Stepwise
annotation on a spec and spock will run each of the test definitions of the Spec in the order they are specified. Look at this example.
Author by
Tomas Romero
Updated on June 16, 2022Comments
-
Tomas Romero almost 2 years
Is there a way to set the order in which tests are executed within an Spock Specification?
For example:
class MySpec extends IntegrationSpec { def 'test A'... def 'test B'... }
I want 'test A' to be execute always before 'test B'
This is because I'm doing some functional tests with Geb and Spock and data is not rolled back between tests.
-
Peter Niederwieser over 11 yearsAnd for Geb, use
Geb(Reporting)Spec
together with@Stepwise
. -
Tomas Romero over 11 yearsWhen extending from IntegrationSpec, @Stepwise works, but when extending GebReportingSpec it doesn't. Any idea why?
-
Tomas Romero over 11 yearsIn fact, it do work with GebReportingSpec. The problem I was having had something to do with my spec extending a base spec. My subSpec has a setup method and i think that that (added to the inheritance) could cause my problem.
-
Tomas Romero over 11 yearsIt's a know issue between @Stepwise and inheritance: groups.google.com/forum/?fromgroups=#!topic/spockframework/…. Also code.google.com/p/spock/issues/detail?id=183. In fact, issued by Pangea.