转载:https://blog.csdn.net/atec2000/article/details/54346242
@RunWith(MockitoJUnitRunner.class)
public class OrderServiceTest {
@InjectMocks
private OrderServiceImpl service;
@Mock
private OrderMapper orderMapper;
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
}
@Test
public void testControllerTest() throws Exception {
OrderPo orderPo = new OrderTruePo();
orderPo.setOrderCustomer(1l);
Mockito.when(orderMapper.getOrderPoByOrderId(any(Long.class))).thenReturn(orderPo);
service.getOrderPoByOrderId(0l);
}
}