Why can I not run all tests but can run individual tests with testfx and gradle

250 Views Asked by At

I have a TornadoFX application and before I added any TestFX tests, all my tests ran fine. Then I added a TestFX test and no tests are run when I run all tests. I can run the TestFX test by itself, or any other test, but not when I just run all tests.

Command I am using for all tests:

./gradlew test

Command I am using for a single test

./gradlew test --tests acceptance.dxf.DXFViewerTest

build.gradle.kts:

plugins {
    java
    kotlin("jvm") version "1.6.10"
    application
    id("org.openjfx.javafxplugin") version "0.0.9"
}

group = "com.protocase.vision"
version = "1.0-SNAPSHOT"

repositories {
    mavenCentral()
}

javafx {
    version = "11.0.2"
    modules("javafx.controls", "javafx.graphics")
}

val koTestVersion = "5.1.0"

dependencies {
    implementation(kotlin("stdlib"))
    implementation( "no.tornado", "tornadofx", "1.7.20")
    implementation("org.openjfx", "javafx", "11.0.2")
    implementation("org.yaml", "snakeyaml", "1.30")
    implementation("gov.nist.math:jama:1.0.3")

    implementation(fileTree(mapOf("dir" to "jars", "include" to listOf("*.jar"))))

    testImplementation("org.jetbrains.kotlin:kotlin-test:1.6.10")
    testImplementation("io.kotest:kotest-runner-junit5:$koTestVersion")
    testImplementation("io.kotest:kotest-assertions-core:$koTestVersion")
    testImplementation("io.kotest:kotest-property:$koTestVersion")
    testImplementation("org.hamcrest:hamcrest-all:1.3")

    testImplementation("io.mockk:mockk:1.12.2")
    testImplementation("org.assertj:assertj-core:3.22.0")
    testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.2")
    testImplementation("org.junit.jupiter:junit-jupiter-params:5.8.2")

    testImplementation("org.testfx:testfx-junit5:4.0.+")
    testImplementation("org.testfx:testfx-core:4.0.+")

    testImplementation(kotlin("script-runtime"))

    testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.8.2")
}


tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
    kotlinOptions.jvmTarget = "11"
}

tasks.withType<Test> {
    useJUnitPlatform()
    systemProperty("java.library.path", "lib")
}

and the one test class I added:

package acceptance.dxf

import javafx.scene.Scene
import javafx.stage.Stage
import org.junit.jupiter.api.Test
import org.testfx.api.FxAssert.verifyThat
import org.testfx.framework.junit5.ApplicationTest
import org.testfx.matcher.control.LabeledMatchers.hasText
import tornadofx.View
import tornadofx.hbox
import tornadofx.label
import tornadofx.vbox


class DXFViewerTest : ApplicationTest() {

    override fun start(stage: Stage) {
        val panel = DXVViewerPanel()

        val scene = Scene(panel.root, 400.0, 600.0)
        stage.scene = scene
        stage.show()
    }

    @Test
    fun `status panel should say no part loaded when controller does not have any layers`() {
        // The viewer's status panel says no part loaded
        verifyThat("#statusLabel", hasText("No Part Loaded"))
    }

}

class DXVViewerPanel : View() {

    override val root = vbox {
        hbox {
            label("No Part Loaded") {
                id = "statusLabel"
            }
        }
    }
}

Note I also have OpenCV in this project which involves natives being loaded.

Any ideas would be very helpful!

0

There are 0 best solutions below