Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determine order of execution of Spock tests

Tags:

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.

like image 408
Tomas Romero Avatar asked Nov 27 '12 01:11

Tomas Romero


People also ask

Does Spock run tests in parallel?

By default, Spock runs tests sequentially with a single thread. As of version 2.0, Spock supports parallel execution based on the JUnit Platform.

What is Spock unit testing?

Spock is a testing and specification framework for Java and Groovy applications. What makes it stand out from the crowd is its beautiful and highly expressive specification language. Thanks to its JUnit runner, Spock is compatible with most IDEs, build tools, and continuous integration servers.


1 Answers

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.

like image 104
Aravind Yarram Avatar answered Sep 17 '22 19:09

Aravind Yarram