@SpringBootTest unit testing the use of different versions of JUnit

  • Junit version problem

    • The annotation introduced by JUnit4 org.junit.Testis 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.Testis the @Test annotation. The normal operation of the springboot test class only needs to add @SpringBootTestannotations , 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)

Supongo que te gusta

Origin blog.csdn.net/weixin_51909882/article/details/125876223
Recomendado
Clasificación