Skip to content

Instantly share code, notes, and snippets.

@jahe
Last active October 20, 2017 07:21
Show Gist options
  • Select an option

  • Save jahe/79113bd174365357d22d167de11758f0 to your computer and use it in GitHub Desktop.

Select an option

Save jahe/79113bd174365357d22d167de11758f0 to your computer and use it in GitHub Desktop.
Spock Cheatsheet
// Ignore a single test within a Specification
class MySpec extends Specification {
@Ignore // spock.lang.Ignore
def "foo"() {
// ...
}
}
// Ignore a whole Specification
@Ignore // spock.lang.Ignore
class MySpec extends Specification {
def "foo"() {
// ...
}
def "bar"() {
// ...
}
}
// Run before every test method in class
def setup() {}
// Run after every test method in class
def cleanup() {}
// Run once in class before any test has run
def setupSpec() {}
// Run once in class after the last test has run
def cleanupSpec() {}
// Extract common assertions to a helper function
def void assertListNotEmpty(list) {
assert list != null
assert list.isEmpty()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment