Skip to content

Instantly share code, notes, and snippets.

@westonal
Last active August 29, 2015 14:22
Show Gist options
  • Save westonal/06284a438166f3e69d78 to your computer and use it in GitHub Desktop.
Save westonal/06284a438166f3e69d78 to your computer and use it in GitHub Desktop.
Groovy Spock Specification Tests

Shows insertion of values in test name. @Unroll is required for this.

import spock.lang.*
@Unroll
class ExampleSpockSpec extends Specification {
def "max of #a and #b is #c"() {
expect:
Math.max(a, b) == c
where:
a | b || c
1 | 2 || 2
3 | 1 || 3
2 | 2 || 2
}
}
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>SpockExample</artifactId>
<version>1</version>
<dependencies>
<dependency>
<groupId>org.spockframework</groupId>
<artifactId>spock-core</artifactId>
<version>1.0-groovy-2.4</version>
</dependency>
</dependencies>
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment