[英]java.lang.ClassNotFoundException: org.junit.platform.engine.ConfigurationParameters Junit5 with eclipse
[英]When using JUnit5, I got a warning: "ClassNotFoundException: org.junit.platform.engine.support.filter.ExclusionReasonConsumingFilter"
我正在嘗試使用 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>
然后,我創建了一個測試:
package com.example.multicurrency;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
class JunitTests {
@Test
void testAssertTrue() {
assertTrue(false);
}
}
之后,我運行測試。 以下是我得到的:
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>
結果如我所料。 但是這個警告讓我感到困惑。 警告是什么意思?
現在將junit-jupiter-engine
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>
似乎您對https://issues.apache.org/jira/browse/SUREFIRE-1564感到震驚,它描述了一個已知問題,即 Surefire 2.22.0
內部保留所有junit-platfrom-xyz
工件的版本1.2.0
。
您還應該嘗試 Surefire 3.xa - afaik,它與所有版本的 JUnit 兼容: https ://maven.apache.org/surefire/maven-surefire-plugin/
我通過更新2017.2到2018.2.4的intellij想法解決了這個問題。 但我還沒弄清楚是什么導致它以及為什么它解決了。
感謝您的友好答案和評論。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.