我的 Kotlin Android 项目有以下依赖项{
dependencies {
...
testImplementation "org.junit.platform:junit-platform-engine:1.0.2"
testImplementation "org.junit.platform:junit-platform-gradle-plugin:1.0.2"
testImplementation "org.junit.platform:junit-platform-launcher:1.0.2"
testImplementation "org.junit.platform:junit-platform-suite-api:1.0.2"
testImplementation "org.junit.jupiter:junit-jupiter-api:5.0.2"
testImplementation "org.junit.jupiter:junit-jupiter-engine:5.0.2"
testImplementation "org.junit.jupiter:junit-jupiter-params:5.0.2"
}
运行测试时出现的错误是:
org.junit.platform.launcher.core.DefaultLauncher handleThrowable
WARNING: TestEngine with ID 'junit-vintage' failed to discover tests
java.lang.NoClassDefFoundError: org/junit/runner/manipulation/Filter
...
Caused by: java.lang.ClassNotFoundException: org.junit.runner.manipulation.Filter
Exception in thread "main" java.lang.NoSuchMethodError: org.junit.platform.launcher.Launcher.execute(Lorg/junit/platform/launcher/LauncherDiscoveryRequest;
如果我的测试引擎 id 是junit-vintage
,那么是否可以更改它?似乎它仍在使用junit 4引擎。我怎样才能改变它,让它使用junit-jupiter?我从依赖项中删除了 junit-4.12,所以我想知道为什么它使用 junit-vintage 引擎而不是 junit-jupiter。
目前使用:
Android Studio 3.0
Build #AI-171.4408382, built on October 20, 2017
JRE: 1.8.0_152-release-915-b01 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0
如果我必须包含 junit-vintage-engine,如果我的所有测试都是用 JUnit5 样式编写的,我为什么需要这样做?