springboot-test配置
文章目录
1.依赖配置
<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.12</version>
<!--<scope>test</scope>-->
</dependency>
2. 测试类
测试类上的注解
@RunWith(SpringRunner.class)
@SpringBootTest
3.注意
测试类需要使用public修饰,测试类中需要启动的方法也需要使用public修饰。