Created
October 14, 2016 04:59
-
-
Save fmamud/441127257c8214f2d9027060d8cd3ea7 to your computer and use it in GitHub Desktop.
Stubbing multiple parameters in 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 return 2 for method parameter equal to 2"() { | |
given: | |
List list = Stub() | |
list.get(0) >> 0 | |
list.get(1) >> { throw new IllegalArgumentException() } | |
list.get(2) >> 2 | |
expect: | |
list.get(2) == 2 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment