首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用TestFX 5在Gradle上安装JUnit

使用TestFX 5在Gradle上安装JUnit
EN

Stack Overflow用户
提问于 2021-11-10 04:22:39
回答 1查看 171关注 0票数 0

我正在努力获得TestFX设置,以便在Gradle项目中使用。我遵循了https://github.com/TestFX/TestFX/blob/master/README.md上的指示,但它似乎仍然给我带来了问题。知道为什么它找不到这个方法吗?

代码语言:javascript
复制
* What went wrong:
A problem occurred evaluating project ':app'.
> Could not find method testCompile() for arguments [org.testfx:testfx-core:4.0.16-alpha] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

gradle.build

代码语言:javascript
复制
plugins {
    // Apply the application plugin to add support for building a CLI application in Java.
    id 'application'
    id 'org.openjfx.javafxplugin' version '0.0.9'
    id 'jacoco'
}

repositories {
    // Use JCenter for resolving dependencies.
    jcenter()
    mavenCentral()
}

dependencies {
    // Use JUnit Jupiter API for testing.
    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.6.2'

    // Use JUnit Jupiter Engine for testing.
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'

    // This dependency is used by the application.
    implementation 'com.google.guava:guava:29.0-jre'

    // Ikonli Text Icons
    implementation 'org.kordamp.ikonli:ikonli-javafx:12.1.0'
    implementation 'org.kordamp.ikonli:ikonli-fontawesome5-pack:12.1.0'
    implementation 'org.kordamp.ikonli:ikonli-materialdesign2-pack:12.1.0'
    implementation 'org.kordamp.ikonli:ikonli-material2-pack:12.1.0'

    // TestFX
    testCompile "org.testfx:testfx-core:4.0.16-alpha"
    testCompile 'org.junit.jupiter:junit-jupiter-api:5.5.1'
    testCompile "org.testfx:testfx-junit5:4.0.16-alpha"
    testCompile group: 'org.hamcrest', name: 'hamcrest', version: '2.1'
}

application {
    // Define the main class for the application.
    mainClass = 'App'
}

tasks.named('test') {
    // Use junit platform for unit tests.
    useJUnitPlatform()
}

javafx {
    version = "17"
    modules = ['javafx.controls', 'javafx.fxml']
}

jacoco {
.
.
.

注意:我确实尝试过在没有改变行为的情况下更改为plugin{id 'org.openjfx.javafxplugin' version '0.0.8'}javafx {version = '12'}

EN

回答 1

Stack Overflow用户

发布于 2022-08-08 03:05:34

尝试一下testImplementation,我相信它已经取代了testCompile

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

https://stackoverflow.com/questions/69907973

复制
相关文章

相似问题

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