如何模拟来自模拟方法的超级方法调用
public class A extends B{
@Override
public retrieveData(){
//some action here
super.retrieveData();
}
}
abstract class B extends C{
//init super fields here
}
public class C{
public String retrieveData(){
//some return
}
}
Public Atest{
@InjectMock
A a;
@Mock
C parent; //also tryed for B but the same effect
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
}
@Test
public void testDetailsRetrievePageList(){
when(parent.retrieveData()).thenReturn("stub");
String s = a.retrieveListData();
Assert.assertEquals("stub", s);
}
}
没有帮助Mockito How to mock only the call of a method of the superclass并发布这样的内容。
每次我的超级A在A类
中为空