java - TestFX和Gradle-NoNodeFoundException

标签 java eclipse gradle javafx testfx

testFx已在Eclipse中运行,并且GUI测试成功运行。但这不适用于gradle。它给我一个按钮上的NoNodeFoundException。
如果我摆脱了那行代码,它会向我显示指向TextField的下一行的相同异常。

似乎除开发人员外,没有人尝试过将testfx与gradle结合使用。

知道如何解决吗?

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"""

//隐私保护
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")
    }
}

不知道这是否有帮助,但这是我的项目结构。
enter image description here

最佳答案

我最近开始在gradle中使用testfx。

这是我的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
}

由于某种原因,如果我有Button loginButton = find("#loginButton");,即使设置了fx:id,我也会得到您提到的异常。仅在设置CSS ID之后才有效:

enter image description here

关于java - TestFX和Gradle-NoNodeFoundException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34832352/

相关文章:

java - 有没有开源的完整的Java EE MDA框架?

java - 在java中使用RandomAccessFile的不完整文件

Eclipse Neon 中的 Javascript 大纲 - Java EE IDE

Eclipse 调试 View 中未显示 Java 源代码

android - Android资源编译失败(缓存文件错误)

java - 无法获取 JAXBContext?

java - 专门从 java.library.path 加载 native 库

java - Eclipse错误:“导入XXX无法解析”

java - 安卓工作室 : Could not get unknown property 'kotlin_version'

java - Gradle compileJava 任务甚至在清理期间运行?