Springboot单元测试

  1. 添加测试支持依赖:spring-boot-starter-test

<dependency>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-test</artifactId>

<scope>test</scope>

</dependency>

注意:加入这个依赖之后,junit包就可以不用了,因为test的starter中包含了junit

 

 

@RunWith(SpringRunner.class) 启动支持类
@SpringBootTest 测试支持
public class TestController {

@Test  //测试方法
public void test(){

}

}
原文地址:https://www.cnblogs.com/java-xz/p/9182028.html