Springboot单元测试的操作步骤:
1.添加依赖spring-boot-starter-test
在pom.xml中添加依赖spring-boot-starter-test

2.在src/test/java下新建java class

3.单元测试入口代码结构
java
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.boot.test.context.SpringBootTest;
@RunWith(SpringRunner.class)
@SpringBootTest(classes =Application.class ) //指定启动类
public class MyController {
@Test
public void test() {
}
}
4.执行
run 单元测试文件

6.执行结果

7.举例
