当前位置: 首页 > 知识库问答 >
问题:

如何更改TestEngine ID以运行JUnit5?

糜征
2023-03-14

我的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;
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风格编写的,为什么还要包含呢?

共有1个答案

唐经国
2023-03-14

如果您使用带有JUnit Jupiter(JUnit 5)的Android,您可能会发现使用android-junit5插件配置Gradle构建更容易。

 类似资料:
  • Mac os对我来说是新的。我最近在MAC OS上安装了MAMP。我已将我的php项目放入 应用程序/MAMP/htdocs 当我执行这个代码我得到的URL作为 因为网址说它使用8888端口,我不想在我的网址8888,因为我的项目有各种重定向。所以我尝试改变MAMP上的端口------ 优势-----imade它设置默认的apace和MySql端口 但是在ist之后,当我重新启动MAMP时,我找到

  • 我已经使用SLF4j作为日志框架,由log4j支持。我的问题是,我正在寻找一种在运行时更改记录器日志记录级别的方法。 我知道slf4j不允许通过自己的API直接进行此操作,因此,我必须直接访问日志提供程序。就个人而言,我发现这是slf4j中的一个巨大缺陷。所以现在我的问题是,如何通过slf4j以编程方式确定我使用的是哪种提供者?使用slf4j的最大目的是让您变得与提供商无关-您可以轻松地在您喜欢的

  • 如何在运行时更改application.yaml的值?例如,我有一个服务器地址属性,希望在运行时更改

  • 如何更改项目运行时平台? (standard NetBeans[8.1]Java Project[Java Application]) 详细信息: 在NetBeans 8.1中使用Ubuntu 我已经安装了JDK 1.6,JDK 1.7+JDK 1.8 我的项目平台是Java6. 我的系统默认Java是Java7。 NetBeans-IDE是用Java8启动的。 我想要的是: Project-Pl

  • 问题内容: 我正在尝试使用goncurses。在Centos 6上,ncurses库很旧(5.7,需要5.9),所以我从源代码构建了ncurses并将其安装到/ usr / lib,/ usr / include等。 如何告诉“ go get”针对/ usr / lib中的内容而不是/ lib中的系统内容运行? 这是我当前的输出: 我已经尝试过上不同的变化,并与出任何行为改变。 我知道这是一个简单