To avoid the Spring context reloading again and again, I have moved @MockBean annotated injection to a parent class, something like this.
@SpringBootTest
.......
public abstract BaseTest {
@MockBean
protected OneService oneService;
This serves the test classes which need a mock for OneService. However, for the test that I would like also extended from BaseTest, but inject the real OneService via @Autowired will not work, as it will inherit the mock injection from the BaseTest.
public AnotherTest extends BaseTest {
@Autowired
protected OneService oneService;
Even I used @Autowired annotation, the oneService field will be the mock instance inherited from BaseTest.
Is there a way I can force inject to use autowired?