如何更改TestEngine ID以运行JUnit 5?

时间:2017-11-18 23:20:16

标签: android junit junit5 junit-jupiter

我的Kotlin Android项目{

有以下依赖项
(a -> m b)

运行测试时出现的错误是:

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"
}

如果我的测试引擎ID为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; ,那么可以更改此设置吗?好像它还在使用junit 4引擎。我怎么能改变它所以它使用junit-jupiter?我从我的依赖项中删除了junit-4.12,所以我想知道它为什么使用junit-vintage引擎而不是junit-jupiter。

目前正在使用:

junit-vintage

如果我必须包含junit-vintage-engine,如果我的所有测试都以JUnit5风格编写,为什么还需要?

1 个答案:

答案 0 :(得分:1)

如果您正在使用Android和JUnit Jupiter(JUnit 5),您可能会发现使用android-junit5插件更轻松地配置Gradle版本。