-
Junit version problem
-
The annotation introduced by JUnit4
org.junit.Test
is the @Test annotation. To ensure the normal operation of the springboot test class, add two annotations@SpringBootTest
,@RunWith(SpringRunner.class)
-
The annotation introduced by JUnit5
org.junit.jupiter.api.Test
is the @Test annotation. The normal operation of the springboot test class only needs to add@SpringBootTest
annotations , no need to add@RunWith(SpringRunner.class)
-
-
The package name of the spring boot unit test class must be consistent with the package name of the project startup class by default. The unit test class should be placed in the same path as the project startup class, and the package name should be the same.
-
When the package name of the test class is inconsistent with the package name of the startup class, it can also be specified manually
@SpringBootTest(classes = DemoApp.class)