我正在努力获得TestFX设置,以便在Gradle项目中使用。我遵循了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'}。
发布于 2022-08-08 03:05:34
尝试一下testImplementation,我相信它已经取代了testCompile
https://stackoverflow.com/questions/69907973
复制相似问题