首页 > 编程语言 > 详细

Springboot使用junit

时间:2018-06-24 23:26:46      阅读:202      评论:0      收藏:0      [点我收藏+]

1. 首先要下载配套的spring-boot-starter-test包,注意版本要对应。

compile("org.springframework.boot:spring-boot-starter-web:2.0.2.RELEASE")

// Use JUnit test framework
testImplementation junit:junit:4.12
// https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-test
testCompile group: org.springframework.boot, name: spring-boot-starter-test, version: 2.0.2.RELEASE

 

2. 示例

@RunWith(SpringRunner.class)
@SpringBootTest(classes = Springboot启动函数.class)
public class NumberServiceT {
    @Autowired
    NumberService ns;

    @Test
    public void getNumberList() {
    //    NumberService ns = new NumberService();
    ns.getUseableNumber();
    }

}

 

Springboot使用junit

原文:https://www.cnblogs.com/yoyotl/p/9185044.html

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