Springboot使用junit

匿名 (未验证) 提交于 2019-12-03 00:34:01

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();     }  }

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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!