1.依赖包
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency>
2.在测试了添加注解
@RunWith(SpringRunner.class) @SpringBootTest
3.使用