https://github.com/mam-dev/spock-order-extension
https://github.com/mam-dev/spock-order-extension
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/mam-dev/spock-order-extension
- Owner: mam-dev
- License: apache-2.0
- Created: 2020-10-15T16:20:56.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2020-10-29T18:00:38.000Z (over 5 years ago)
- Last Synced: 2026-01-14T03:49:13.455Z (5 months ago)
- Language: Java
- Size: 26.4 KB
- Stars: 0
- Watchers: 19
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.adoc
- License: LICENSE
Awesome Lists containing this project
README
= Spock Order Extension
This extension gives the opportunity to define the order between specs and its parent.
Like `@Stepwise` it ensures a defined execution order and skipps all the following features if a feature fails.
Unlike `@Stepwise` it effects the complete hierarchy and lets you modify the execution order.
.Reasons to use this extension
- you want to start your test with a feature of the child spec
- you want to skip features of your base spec
== Usage
Add dependency
[source,xml]
.pom.xml
----
net.oneandone.spock
order-extension
0.1
test
----
Annotate your spec with `@Order` and define order with annotations:
`@After` and `@Before`.
[source,groovy]
.OrderExtensionFullExampleTest
----
@Order(skip = 'base 5')
class OrderExtensionFullExampleTest extends Base {
@After("base 1")
def "child 1"() {
expect: true
}
def "child 2"() {
expect: true
}
@Before("base 2")
def "child 3"() {
expect: true
}
@After("base 3") @Before("base 4")
def "child 4"() {
expect: true
}
}
class Base extends Specification {
def "base 1"() {
expect: true
}
def "base 2"() {
expect: true
}
def "base 3"() {
expect: true
}
def "base 4"() {
expect: true
}
def "base 5"() {
expect: true
}
}
----
This gives the following execution order:
- base 1
- child 1 `@After("base 1")`
- child 2 _after step1 due to declaration order_
- child 3 `@Before("base 2")`
- base 2
- base 3 _after base2 due to declaration order_
- child 4 `@After("base 3") @Before("base 4")`
- base 4
- _base 5 (skipped)_ `@Order(skip = 'base 5')`
== Hints
- Features which are not annotated are executed in declaration order
- If `@After` does not point to the last base feature it must be followed by `@Before`, so that it's clear when to continue the execution with the base features.