Is it possible to define a behavior of a mock in the setup() method and then override it in some test methods? Something like this:
SomeMockableObject smo = Mock()
def setup() {
smo.returnSomething() >> "foo"
}
def "test method that expects smo to return 'foo'"() {
// some test code
}
def "test method that expects smo to return 'bar'"() {
given:
smo.returnSomething() >> "bar"
// some test code
}
I have tried this, but smo.returnSomething() always returns "foo". Am I doing something wrong or is it just not possible to do this?