Description
Right now only way of mocking stuff in spring-boot-tests is using mockito which is awesome if you are writing your tests in java but if you are using spock then you might want to use spock mocks. With spock 1.1 one can create detachable mocks not bounded to Specification class instance. It would be great if it would be possible to allow plug in different mocking framework. Spring will ship with mockito as it is now, but spock will be able to provide some classes which will provide custom mock factory.
I've been trying to investigate this issue on my own (and do it in my project) and here is what I found out.
Class org.springframework.boot.test.mock.mockito.MockitoPostProcessor would be good entry point to start. There is pretty promising method org.springframework.boot.test.mock.mockito.MockitoPostProcessor#createMock (with spies it is more complicated and I stopped searching after I tripped over this one), but classes MockDefinition and SpyDefinition are package private (for starters) and method createMock is protected final
so it is impossible to override.
imho mock creation should be abstracted somehow and it should open MockitoPostProcessor (not only mockito any more) for different mocking libraries (like spocks detachable beans).
What do you think about it? Would you consider accepting PR which will mess around in mockito package