Is it possible to replace an inherited @MockBean
with the real @Bean
?
I have an abstract class that defines many configurations and a setup for all ITests. Only for one single test I want to make use of the real bean, and not used the mocked one. But still inherit the rest of the configuration.
@Service
public class WrapperService {
@Autowired
private SomeService some;
}
@RunWith(SpringRunner.class)
@SpringBootTest(...)
public abstract class AbstractITest {
//many more complex configurations
@MockBean
private SomeService service;
}
public class WrapperServiceITest extends AbstractITest {
//usage of SomeService should not be mocked
//when calling WrapperService
//using spy did not work, as suggested in the comments
@SpyBean
private SomeService service;;
}