0

Disclaimer: I do understand that the tests should be isolated and the order should not matter. And in most of cases it really doesn't matter. Please see below the explanation of the case.

Some tests should be executed under the same user, but with different roles. The issue is that roles can be set by the user himself, from 'higher' to 'lower', e.g.: administrator, developer, reporter. To set the 'administrator' role again, the full application's re-build is required and there is no way for now to have several test users.

So it is important to execute the 'administrator' tests first, then 'developer' and then 'reporter'. Is there a way in Spock to set the Specs suite with particular spec execution order? Or maybe there is a way in Gradle to order the specs?

For now I spited the tests by packages and call the test task several times by passing the --tests filter. But this looks not so good.

Bohdan Nesteruk
  • 794
  • 17
  • 42
  • Haven't used it, but the [spock wiki](https://github.com/spockframework/spock/wiki/Third-Party-Extensions) lists this extension, which may be useful: https://github.com/1and1/spock-order-extension ... or ... spock uses JUnit Platform under the hood, so [this](https://junit.org/junit5/docs/current/user-guide/#writing-tests-test-execution-order-classes) may _just work_ – thehole Oct 12 '21 at 14:29
  • There is currently no built-in support for ordering Specifications in Spock 1.x and 2.0. – Leonard Brünings Oct 13 '21 at 01:16

0 Answers0