如何为服务层编写测试用例

时间:2019-01-29 06:48:39

标签: java spring-boot junit mockito

我想在独立模拟模式下测试我的服务层。然后我得到错误 测试类别说明

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {TestContext.class, AppConfig.class, SecurityConfig
        .class, LDAPProperties.class, LDAPUserDetailsService.class})
@WebAppConfiguration

@Before
    public void setUp(){
        MockitoAnnotations.initMocks(this);
        Mockito.reset(employeeDao);
        mockMvc= MockMvcBuilders.webAppContextSetup(webApplicationContext).build();
    }

错误

Wanted but not invoked:
employeeDao.getEmployeeByUId("name.dz");
-> at io.dzone.manager.service.EmployeeServiceImplTest.getEmployeeByUIdTest(EmployeeServiceImplTest.java:80)
Actually, there were zero interactions with this mock.

0 个答案:

没有答案