gradle - 使用 JUnit 5 在 Gradle 上设置 TestFX
问题描述
我正在努力获得用于 Gradle 项目的 TestFX 设置。我按照https://github.com/TestFX/TestFX/blob/master/README.md上的说明进行操作,但它似乎仍然给我带来了问题。任何想法为什么它没有找到方法?
* 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
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'}
没有改变行为。
解决方案
推荐阅读
- xml - 组合 xpath 表达式
- typescript - 使用我的 Typescript 组件时,故事书中不支持“const”枚举
- ruby-on-rails - Rails 在符合多个条件的连接中查找所有项目
- python - 重新排列 Pandas 数据框
- java - 在 Java Springboot 中为 mySQL 自定义生成的具有持久序列的列值
- algorithm - 如何在块算法中显示“if operator in for operator”?
- core-audio - PCM中的音频帧样本类型?
- c# - Kubectl 以交互方式应用 .NET Core 控制台应用程序,并在 Kubernetes 上退出 Console.ReadLine
- javascript - 我无法捕获 Select2 事件 - 我怀疑我使用了错误的 jquery 选择器
- google-chrome - MediaRecorder Chrome 编解码器/容器无法在移动设备或 Safari 上播放