0

testFx already works in Eclipse and the GUI tests run successfully. But it does not work with gradle. It gives me the NoNodeFoundException on a button. If I get rid of that line of code that it shows me the very same exception for the next line which points on a TextField.

It seems like noone ever tried to use testfx in combination with gradle besides the developer.

Any idea how to solve that?

gradle.build

apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'checkstyle'
apply plugin: 'application'
apply plugin: 'jacoco'


group = 'TodoManager'
version = '0.0.1'
description = """Aufgabenplanung"""

//privacy protection mainClassName = "*********.todomanager.model.ReadAndWrite"

defaultTasks 'clean', 'test', 'build', 'jacocoTestReport','distZip','javadoc','wrapper'


repositories {

   maven { url "http://repo.maven.apache.org/maven2" }
     jcenter()
     mavenCentral()
}


jar {
    baseName = 'TodoManager'
    version =  '0.5.0'
}

dependencies {

/*
    testCompile group: "org.loadui", name: "testFx", version: "3.1.2"
    testCompile "org.testfx:testfx-core:4.0.+"
    testCompile "org.testfx:testfx-junit:4.0.+"
    compile files('lib/TodoManagerLibrary-1.1.jar')
    testCompile 'junit:junit:4.+'
   */
   testCompile group: "org.loadui", name: "testFx", version: "3.1.2"
    testCompile "junit:junit:4.10"
    testCompile "org.testfx:testfx-core:4.0.+"
    testCompile "org.testfx:testfx-legacy:4.0.+", {
        exclude group: "junit", module: "junit"
    }
}

checkstyle {
    sourceSets = [sourceSets.main]
}

jacoco {
    toolVersion = "0.7.1.201405082137"
    reportsDir = file("$buildDir/reports/jacoco")
}

jacocoTestReport {
    reports {
        xml.enabled false
        csv.enabled false
        html.destination "$buildDir/reports/jacoco/html"
    }
        classDirectories = files('build/classes/')
}

test {

    jacoco {
        append = false
        destinationFile = file("$buildDir/jacoco/jacocoTest.exec")
        classDumpFile = file("$buildDir/jacoco/classpathdumps")
    }
}

Don't know if that is any helpful but here is my project structure. enter image description here

Quatsch
  • 361
  • 1
  • 8
  • 29

1 Answers1

0

I recently started using testfx with gradle.

Here is my build.gradle:

plugins{
    id 'application'
    id 'com.github.johnrengelman.shadow' version '1.2.3'
}

mainClassName = "dialogio.Dialogio"
repositories {
    mavenCentral()
}
dependencies{
    compile 'com.google.guava:guava:19.0'
    compile 'org.controlsfx:controlsfx:8.40.10'
    testCompile 'org.loadui:testFx:3.1.0'
}
test {
  testLogging.showStandardStreams = true
}

For some reason, if I had Button loginButton = find("#loginButton");, I would get the exception you mentioned even though I set the fx:id. It only worked after I set the CSS id:

enter image description here

chenshuiluke
  • 319
  • 1
  • 16