Java 在使用JUnit5时,我得到了一个警告:“您必须遵守《全国人大常委会关于维护互联网安全的决定》及中华人民共和国其他有关法律法规。”;ClassNotFoundException:org.junit.platform.engine.support.filter.ExclutionReasonConsumingFilter“;

Java 在使用JUnit5时,我得到了一个警告:“您必须遵守《全国人大常委会关于维护互联网安全的决定》及中华人民共和国其他有关法律法规。”;ClassNotFoundException:org.junit.platform.engine.support.filter.ExclutionReasonConsumingFilter“;,java,junit,junit5,Java,Junit,Junit5,我正在尝试使用JUnit5。 首先,我向maven项目添加了依赖项: <dependencies> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-engine</artifactId> <version>5.3.0</version>

我正在尝试使用JUnit5。
首先,我向maven项目添加了依赖项:

<dependencies>
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-engine</artifactId>
        <version>5.3.0</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.junit.platform</groupId>
        <artifactId>junit-platform-runner</artifactId>
        <version>1.3.0</version>
        <scope>test</scope>
    </dependency>
</dependencies>
之后,我运行测试。以下是我得到的:

org.junit.platform.launcher.core.DefaultLauncher handleThrowable
warning: TestEngine with ID 'junit-vintage' failed to discover tests
java.lang.NoClassDefFoundError: org/junit/platform/engine/support/filter/ExclusionReasonConsumingFilter
Caused by: java.lang.ClassNotFoundException: org.junit.platform.engine.support.filter.ExclusionReasonConsumingFilter

org.opentest4j.AssertionFailedError: 
Expected :<true> 
Actual   :<false>
org.junit.platform.launcher.core.DefaultLauncher handleThrowable
警告:ID为“junit vintage”的TestEngine未能发现测试
java.lang.NoClassDefFoundError:org/junit/platform/engine/support/filter/ExclutionReasonConsumingFilter
原因:java.lang.ClassNotFoundException:org.junit.platform.engine.support.filter.ExclutionReasonConsumingFilter
org.opentest4j.AssertionFailedError:
预期:
实际:

结果是我所期望的。但是这个警告把我弄糊涂了。警告的含义是什么?

现在使用junit jupiter引擎的版本
5.3.x
和Surefire
2.22.2

<dependencies>
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-engine</artifactId>
        <version>5.3.2</version>
        <scope>test</scope>
    </dependency>
</dependencies>

org.junit.jupiter
它描述了一个已知的问题,即Surefire
2.22.0
对于所有的
junit platfrom xyz
工件,在内部保持版本
1.2.0


您还应该尝试一下Surefire 3.x,因为它似乎与JUnit的所有版本都兼容:

,因为您的项目中不需要JUnit4测试。如果是,请删除对junit platform runner的依赖项。。。只需通过JUnit4 runner启动JUnit平台。详见@Sormuras,谢谢。我删除了juinit platform runner,它确实有效。但是我发现更新我的intellij想法也可以解决我的问题。从5.5.2降级到5.3.2解决了这个问题。谢谢上面添加:“您还应该尝试一下Surefire 3.x-afaik,它与JUnit的所有版本兼容:”
<dependencies>
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-engine</artifactId>
        <version>5.3.2</version>
        <scope>test</scope>
    </dependency>
</dependencies>