Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
Description
The following script leads to an exception. The closure does not delegate to the Mock.
import groovy.mock.interceptor.StubFor class Foo { def createBar() { throw new RuntimeException("We should never get here!") } } StubFor fooStub = new StubFor(Foo) fooStub.demand.createBar { "I'm a mock" } Closure closure = { createBar() } fooStub.use { Foo foo = new Foo() assert "I'm a mock" == foo.createBar() closure.delegate = foo assert "I'm a mock" == closure.call() }