环境配置
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
代码及介绍
…当我们用JUnit4的时候,像是SpringBoot容器中的对象我们都无法得到。
现在使用JUnit5之后,当需要SpringBoot容器中对象时,可以添加注解:@SpringBootTest
除此以外下面的代码是JUnit5中比较常用的注解(有些注解方法没写,只是做了简单的介绍,用法查询百度)
@SpringBootTest
public class JUnit5Test {
//为测试类或测试方法设置展示名称
@Test