首先需要注释:
@RunWith(SpringRunner.class)
@SpringBootTest
再者,引入的@Test的包是org.junit.Test 不是org.junit.jupiter.api.Test;
引入依赖:
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<scope>test</scope>
</dependency>