Mock invocation order is based on method return order, not invocation
Opened this issue · 0 comments
GoogleCodeExporter commented
This fails:
def "spock bug"() {
given:
def r1 = Mock(Runnable)
def r2 = Mock(Runnable)
def r3 = { r1.run() }
when:
r3()
then:
1 * r1.run() >> { r2.run() }
then:
1 * r2.run()
}
While this passes:
def "spock bug"() {
given:
def r1 = Mock(Runnable)
def r2 = Mock(Runnable)
def r3 = { r1.run() }
when:
r3()
then:
1 * r2.run()
then:
1 * r1.run() >> { r2.run() }
}
Spock thinks r2.run() was called first because it returned before r1.run().
Original issue reported on code.google.com by l...@gradleware.com
on 12 Mar 2014 at 9:53