Spock Scope Extension

An extension to mark tests as belonging to a (set of) scopes (e.g. a global feature or a major aspect of the application) for the Spock Framework (see http://spockframework.org/).

License

License

Categories

Categories

Spock Application Testing & Monitoring
GroupId

GroupId

de.assertagile.spockframework.extensions
ArtifactId

ArtifactId

spock-scope-extension
Last Version

Last Version

0.4
Release Date

Release Date

Type

Type

jar
Description

Description

Spock Scope Extension
An extension to mark tests as belonging to a (set of) scopes (e.g. a global feature or a major aspect of the application) for the Spock Framework (see http://spockframework.org/).
Project URL

Project URL

https://github.com/mkutz/spock-scope-extension
Source Code Management

Source Code Management

https://github.com/mkutz/spock-scope-extension

Download spock-scope-extension

How to add to project

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

Dependencies

compile (1)

Group / Artifact Type Version
org.codehaus.groovy : groovy-all jar 2.4.5

provided (2)

Group / Artifact Type Version
org.spockframework : spock-core jar 1.0-groovy-2.4
org.slf4j : slf4j-api jar 1.7.12

test (3)

Group / Artifact Type Version
cglib : cglib jar 3.1
org.objenesis : objenesis jar 2.2
ch.qos.logback : logback-classic jar 1.1.3

Project Modules

There are no modules declared in this project.

Spock Scope Extension

Build Status Coverage Status Maven Central

An extension to mark tests as belonging to a (set of) scopes (e.g. a global feature or a major aspect of the application) for the Spock Framework.

When executing a Specification marked @Scope([FeatureA, FeatureB]) and the configured current scope is [FeatureC, FeatureD], the test will be set "ignored" while all tests that are marked with a set of scopes containing at least one FeatureC or FeatureD will still be executed. Specification not having a @Scope annotation will be executed as well.

Usage

For a detailed view on how to use this extension please have a look into the demonstation folder of this repository.

Add this as a test dependency to your project.

For instance in your pom.xml:

<dependency>
  <groupId>de.assertagile.spockframework.extensions</groupId>
  <artifactId>spock-scope-extension</artifactId>
  <version>${spock-scope-extension.version}</version>
  <scope>test</scope>
</dependency>

Now you can mark your Specifications or their feature methods with the @Scope(…) annotation with one or more subclasses of SpecScope representing scopes.

When you execute your tests you can pass -Dspock.scopes=… to your test execution, all tests that are not annotated with at least one of the given scopes, it will be ignored.

You can as well pass -Dspock.excludedScopes=… to ignore all tests that have at least one of the given scopes (since v0.3).

Note that all unscoped Specification and feature methods will be ignored when you set scopes (included or exclued). If you want to include unscoped tests, you can use the pseudo scope UNSCOPED (since v0.4).

To ease usage in IDE's you can as well create a SpockScopeConfig.groovy to your projects resources and add a list of includedScopes and excludedScopes instead of the -Dspock.scopes=… and -Dspock.excludedScopes=… parameters:

includedScopes = [FeatureA, FeatureC]
excludedScopes = [FeatureB]

Note that if neither includedScopes nor excludedScopes is configured and neither -Dspock.scopes=… nor -Dspock.excludedScopes=… are set the extension will not ignore any test.

Also note that the -Dspock.scopes=… and -Dspock.excludedScopes=… parameters will always replace the configuration in SpockScopeConfig.groovy if given.

Alternative

Instead of using this custom extension, you could also use Spock's own (undocumented) runner configuration mechanism.

Check the source in this demonstration folder for some examples how to use it.

This was derived from the IncludeExcludeExtensionSpec in the spock-example project. Checkout the GroovyDoc on the file for more details.

Versions

Version
0.4
0.3
0.2
0.1