I have code that looks like this:
@ExtendWith(MockitoExtension.class)
class MyTest{
@Mock
private ClassA classA;
@InjectMocks
private ClassB classB;
//Tests omitted
}
@Service
class ClassB{
private final String stuff;
ClassB(ClassA classA){
this.stuff = classA.getStuff();
}
// Code omitted
}
I need to mock the getStuff method. How do I mock the method before the injectmocks annotation is injecting my mock of ClassA? This is really easy without annotations but I would like to do it with annotations if possible.