1、导入pom坐标

junit

junit

4.12

test

org.springframework

spring-test

5.2.10.RELEASE

2、编写测试用例

@RunWith(SpringJUnit4ClassRunner.class)

@ContextConfiguration(classes = SpringConfig.class)

public class AccountServiceTest {

@Autowired

private AccountService accountService;

@Test

public void TestFindById(){

System.out.println( accountService.findById(1));

}

}

@RunWith   指定测试用例类型@ContextConfiguration 指定测试SpringConfig配置类 @Autowired  自动装配@Test  表明这个是测试用例

相关链接

评论可见,请评论后查看内容,谢谢!!!
 您阅读本篇文章共花了: