We should note in the documentation that @MockBean cannot be used to mock the behaviour of a bean that's exercised during application context refresh. It does not work as application context refresh has completed before the test gets a chance to configure the mocked behaviour.