使用springboot写单元测试
1.添加依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>1.5.6.RELEASE</version>
<scope>test</scope>
</dependency>
版本可以任意选择
2.添加注解
@SpringBootTest() @RunWith(SpringRunner.class) @ContextConfiguration(classes = XqaWebApplication.class)
SpringbootTest注解完成类的加载等功能
ContextConfiguration注解用来配置上下文
原文:https://www.cnblogs.com/zshjava/p/10563863.html