Class A {
B b;
C c;
}
Class C {
D d;
E e;
}
I want to write unit test for A but I do not want to mock methods of C. However, I do want to mock D and E in C.
I have tried these options: Option 1:
@Mock B b;
@Mock D d;
@Mock E e;
@Spy @InjectMocks C c;
@InjectMocks A a;
Option 2:
@Mock B b;
@Mock D d;
@Mock E e;
@Spy C c = Mockito.spy(new C(d,e));
@InjectMocks A a;
Option 3: suggestions in Mockito Inject mock into Spy object
None of the options are working for me. Will appreciate any help.