Last active
October 20, 2017 07:21
-
-
Save jahe/79113bd174365357d22d167de11758f0 to your computer and use it in GitHub Desktop.
Spock Cheatsheet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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