首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何更改TestEngine ID以运行JUnit 5?

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

Stack Overflow用户
提问于 2017-11-18 23:20:16
回答 1查看 1.3K关注 0票数 1

对于我的Kotlin Android项目,我有以下依赖项:{

代码语言:javascript
复制
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"
}

在运行测试时遇到的错误是:

代码语言:javascript
复制
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-木星?我把junit-4.12从我的依赖项中删除了,所以我想知道为什么它使用junit-老式引擎而不是junit-junit-木星。

目前使用:

代码语言:javascript
复制
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引擎,那么如果我的所有测试都是用JUnit5风格编写的,我为什么要这样做呢?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-11-20 15:46:19

如果你使用安卓与JUnit木星(JUnit 5),你可能会发现更容易配置你的梯度构建使用安卓-军政府5插件。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47372123

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档