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修饰。
本文详细介绍SpringBoot项目中如何进行单元测试配置,包括依赖引入、测试类注解使用及注意事项,适合初学者快速上手。
2821

被折叠的 条评论
为什么被折叠?



