public class AbstractServiceTest {
@Test
public void execute() throws Exception {
AbstractService abstractService = Mockito.mock(AbstractService.class,
Mockito.CALLS_REAL_METHODS);
Log logger = mock(Log.class);
doNothing().when(logger).info(any());
ReflectionTestUtils.setField(abstractService, "logger", logger);
when(abstractService.isSuccess(any())).thenReturn(true);
abstractService.execute(new 参数());
}
测抽象类中的实现方法,用 Mockito.CALLS_REAL_METHODS 表示进入具体方法