我正在尝试在JUnit5测试环境中使用JUnit4。实际上,我已经将pom升级为使用更高版本的MOckito和POwerMock。直到现在,所有测试都基于JUnit4。我将平台和老式依赖项添加到了pom.xml中。现在,我的任何JUnit4测试用例都没有运行。
早期的pom.xml依赖项
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>1.9.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>1.6.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito</artifactId>
<version>1.6.1</version>
<scope>test</scope>
</dependency>
Latest pom.xml dependencies
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>5.3.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>2.23.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>2.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito2</artifactId>
<version>1.7.4</version>
<scope>test</scope>
</dependency>
i m getting below errors
Errors:
[ERROR] IntegratorAccessUpdateTest.testBeanProperties:13 » NullPointer
[ERROR] ActionHistoryTest.testBeanProperties » StackOverflow
[ERROR] ApplicationPreferenceManagerTest.testGetBoolean » NoClassDefFound org/powermoc...
[ERROR] ApplicationPreferenceManagerTest.testGetString » NoClassDefFound org/powermock...
[ERROR] CommonValidatorsDispatcherTest.setUp:25 » IllegalState Could not initialize pl...
[ERROR] CommonValidatorsDispatcherTest.setUp:25 » IllegalState Could not initialize pl...
How can i remove these errors, I am not sure that changing each and every class is feasible.is there is any compatibility issue with the versions? why is it showing stackoverflow error?
答案 0 :(得分:0)
Junit提供有关如何从Junit4升级到Junit5的指南。 https://junit.org/junit5/docs/current/user-guide/#migrating-from-junit4