0

I'm working to get TestFX setup for use on a Gradle project. I followed the directions on https://github.com/TestFX/TestFX/blob/master/README.md but it still seems to give me problems. Any ideas why it isn't finding the method?

* 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 {
.
.
.

Note: I did try changing to plugin{id 'org.openjfx.javafxplugin' version '0.0.8'} and javafx {version = '12'} with no change in behavior.

2 Answers2

0

try with testImplementation I Believe that has replaced testCompile

0

Late answer, but I found the question so I thought I'd answer it.

Found the answer here: build-error-with-gradle-could-not-find-method-testcompile

If gradle can't find method testCompile() it is probable that you need to replace the deprecated testCompile by testImplementation like this

testImplementation "org.testfx:testfx-core:4.0.16-alpha"
Niklas B
  • 1
  • 1