net.oneandone.spock:order-extension

Parent POM for 1-and-1 open source projects. Defines often used dependencies and plugins.

License

License

Categories

Categories

Spock Application Testing & Monitoring Net
GroupId

GroupId

net.oneandone.spock
ArtifactId

ArtifactId

order-extension
Last Version

Last Version

0.1
Release Date

Release Date

Type

Type

jar
Description

Description

Parent POM for 1-and-1 open source projects. Defines often used dependencies and plugins.
Project URL

Project URL

https://github.com/1and1/spock-order-extension
Project Organization

Project Organization

1&1
Source Code Management

Source Code Management

https://github.com/1and1/spock-order-extension/

Download order-extension

How to add to project

<!-- https://jarcasting.com/artifacts/net.oneandone.spock/order-extension/ -->
<dependency>
    <groupId>net.oneandone.spock</groupId>
    <artifactId>order-extension</artifactId>
    <version>0.1</version>
</dependency>
// https://jarcasting.com/artifacts/net.oneandone.spock/order-extension/
implementation 'net.oneandone.spock:order-extension:0.1'
// https://jarcasting.com/artifacts/net.oneandone.spock/order-extension/
implementation ("net.oneandone.spock:order-extension:0.1")
'net.oneandone.spock:order-extension:jar:0.1'
<dependency org="net.oneandone.spock" name="order-extension" rev="0.1">
  <artifact name="order-extension" type="jar" />
</dependency>
@Grapes(
@Grab(group='net.oneandone.spock', module='order-extension', version='0.1')
)
libraryDependencies += "net.oneandone.spock" % "order-extension" % "0.1"
[net.oneandone.spock/order-extension "0.1"]

Dependencies

compile (2)

Group / Artifact Type Version
org.spockframework : spock-core jar 1.3-groovy-2.5
junit : junit jar 4.12

test (1)

Group / Artifact Type Version
org.jetbrains : annotations jar RELEASE

Project Modules

There are no modules declared in this project.

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

pom.xml
<dependencies>
    <dependency>
        <groupId>net.oneandone.spock</groupId>
        <artifactId>order-extension</artifactId>
        <version>0.1</version>
        <scope>test</scope>
    </dependency>
</dependencies>

Annotate your spec with @Order and define order with annotations: @After and @Before.

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.

net.oneandone.spock

1&1

Open Source by 1&1 Group.

Versions

Version
0.1