引入依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<!--<scope>test</scope>-->
</dependency>
将test类建在和启动类一致的包下
类上添加注解
@SpringBootTest @RunWith(SpringRunner.class)
方法上加上@Test就可以运行了