Skip to content

Instantly share code, notes, and snippets.

@fmamud
Created October 14, 2016 04:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fmamud/441127257c8214f2d9027060d8cd3ea7 to your computer and use it in GitHub Desktop.
Save fmamud/441127257c8214f2d9027060d8cd3ea7 to your computer and use it in GitHub Desktop.
Stubbing multiple parameters in Spock Specification
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