junit
依赖:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
然后在测试包的测试类上添加:
@SpringbootTest(classes={xxxapplication.class})//里面放启动器的类
@RunWith (SpingJUnit4ClassRunner.class) //启动器
SpingJUnit4ClassRunner.class:让junit与spring环境进行整合
@SpringbootTest(classes={xxxapplication.class})有两层含义:
1:当前类为SpringBoot的测试类
2:加载SpringBoot启动类,启动Springboot项目
其他操作就跟mvc的操作一样的