Skip to content

Instantly share code, notes, and snippets.

@fmamud
Created October 14, 2016 04:37
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/cbe01303a00da4de730af535d9c169a7 to your computer and use it in GitHub Desktop.
Save fmamud/cbe01303a00da4de730af535d9c169a7 to your computer and use it in GitHub Desktop.
Stubbing Spock Specification
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