@RunWith(MockitoJUnitRunner.class)
public class MockitoDemo {
@Spy
@InjectMocks
private InjectService injectService; // 这个调用了下面的 mockService
@Mock
private MockService mockService;
@Test
public void test() {
Mockito.doReturn(1).when(mockService).方法名(模拟参数);
Assert.assertEquals(期望返回的结果, injectService.方法名(参数));
}
}
网友评论