项目场景:
单元测试,业务层单个测试
问题描述:
测试瞬间报空指针
原因分析:
spring boot没有启动,没有去调用他
涉及到了
@Test的两个包
import org.junit.jupiter.api.Test
import org.junit.Test
解决方案:
用第一种的,
注意junit依赖用spring boot的避免依赖冲突
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>2.4.2</version>
<scope>test</scope>
</dependency>