-
Notifications
You must be signed in to change notification settings - Fork 474
Closed
Description
Originally reported on Google Code with ID 199
Describe the enhancement you have in mind.
interactions in given/setup blocks should have precedence over those in setup methods
as discussed in: http://groups.google.com/group/spockframework/browse_thread/thread/3e20f7466dd6248b
Is it possible to override the behaviour (return value) for one
specific test method: see example below (also available at:
http://meetspock.appspot.com/script/36001)
"testing exceptional behaviour" fails where I want it to succeed
interface MyInterface {
int myMethod()
}
class MyInterfaceTest extends Specification {
def myInterface = Mock(MyInterface)
def setup() {
myInterface.myMethod() >> 1
}
def "testing regular behaviour"() {
when:
def result = myInterface.myMethod()
then:
result == 1
}
def "testing exceptional behaviour"() {
given:
myInterface.myMethod() >> 2
when:
def result = myInterface.myMethod()
then:
result == 2
}
}
Which particular problem would this enhancement solve for you?
it would ease the setup of testing expetional behaviour, where for all other tests
use the same 'normal' behaviour of the mock, so you don't have to setup this for each
test.
Please provide any additional information below. You can also assign
labels.
Reported by frederic.pape
on 2011-09-13 11:08:13
yuppie-flu, jdpopkin and yonidoronpeters