In Grails 3.2.x and earlier I could do something like this in a spock unit test:
def myServiceMock = Mock(MyService) {
someMethod() >> 42
}
Closure doWithSpring() {{ ->
myService(InstanceFactoryBean, myServiceMock, MyService)
}}
def "some test"(){
expect:
service.myService.someMethod() == 42
}
This would enable the mock to be injected in collaborating classes.
See: http://docs.grails.org/3.2.4/guide/testing.html Under the "doWithSpring and doWithConfig callback methods, FreshRuntime annotation" section.
In Grails 3.3.2 it does not seem to work anymore. And the mention of it has been removed from the testing documentation.
Is there any way to accomplished that behaviour again?
Many thanks in advance!
/brian