Created
October 14, 2016 04:37
-
-
Save fmamud/cbe01303a00da4de730af535d9c169a7 to your computer and use it in GitHub Desktop.
Stubbing Spock Specification
This file contains 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
import spock.lang.* | |
class MySpec extends Specification { | |
def "should size list return always 3"() { | |
given: | |
List list = Stub() | |
list.size() >> 3 | |
expect: | |
list.size() == 3 | |
} | |
def "should thrown exception when calling size list"() { | |
given: | |
List list = Stub() | |
list.size() >> { throw new IllegalStateException() } | |
when: | |
list.size() | |
then: | |
thrown(IllegalStateException) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment