I've got Spring service A
which internally uses service B
.
I want:
- Mock service
B
- Set mocked version into service
A
- Test service
A
behavior - Set previous version of service
B
to serviceA
(reset state)
The problem is last step - I can remember B
at setup
and set it in cleanup
stages. But can I configure to do it automatically (something similar to @ConfineMetaClassChanges
)
This isn't supported out-of-the-box, but it could be implemented as a JUnit rule or Spock extension. (
@ConfineMetaClassChanges
is a Spock extension.)