首页 > 编程语言 > 详细

springboot整合junit

时间:2019-11-05 23:53:33      阅读:151      评论:0      收藏:0      [点我收藏+]

1添加test依赖

<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

2创建SbootTest测试类

3在测试类上添加注解

4在测试类注入测试对象

 

@RunWith(SpringRunner.class)
@SpringBootTest(classes = HelloApplication.class)
public class SbootTest {
    @Autowired
    private UserMapper userMapper;
    @Test
    public void getUserList(){
        List<MUser> userList=userMapper.getUserList();
        for (MUser user:userList){
            System.out.println(user);
        }
    }
}

 

 

 

springboot整合junit

原文:https://www.cnblogs.com/proyuan/p/11802417.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!