3

I'm working on a JavaFX (using TornadoFX) project and I'd like to test it in a headless environment (Circle CI).

I've tried what's written here but it does not work. No matter how I configure TextFX I always get the

Graphics Device initialization failed for :  es2, sw
Error initializing QuantumRenderer: no suitable pipeline found
java.lang.RuntimeException: java.lang.RuntimeException: Error initializing QuantumRenderer: no suitable pipeline found
    at com.sun.javafx.tk.quantum.QuantumRenderer.getInstance(QuantumRenderer.java:280)
    at com.sun.javafx.tk.quantum.QuantumToolkit.init(QuantumToolkit.java:221)
    at com.sun.javafx.tk.Toolkit.getToolkit(Toolkit.java:205)
    at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:209)
    at com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:675)
    at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:695)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$155(LauncherImpl.java:182)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.RuntimeException: Error initializing QuantumRenderer: no suitable pipeline found
    at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.init(QuantumRenderer.java:94)
    at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:124)
    ... 1 more

exception. If I run the tests on my computer I can see the JavaFX window pop up and the robot clicks stuff on the screen.

This is how my test looks like:

class PanelTest : ApplicationTest() {

    lateinit var panel: Panel

    override fun start(stage: Stage) {
        panel = Panel("foo")
        panel.id = "some-panel"
        val scene = Scene(panel, 800.0, 600.0)
        stage.scene = scene
        stage.show()
    }

    @Test
    fun test() {
        rightClickOn("#some-panel")
    }

    companion object {

        @BeforeClass
        fun setupSpec() {
            System.setProperty("testfx.robot", "glass")
            System.setProperty("glass.platform", "Monocle")
            System.setProperty("monocle.platform", "headless")
            System.setProperty("prism.order", "sw")
            System.setProperty("prism.text", "t2k")
            System.setProperty("java.awt.headless", "true")
            registerPrimaryStage()
        }
    }
}

I also tried setting headless mode from gradle but it does not work either:

junitPlatformTest {
    jvmArgs "-Dheadless=true"
}

If I pass all the above parameters as jvm arguments I still see the JavaFX window pop up.

How do I force headless mode for my tests? I tried this, this, this and this as well but nothing seems to work.

Adam Arold
  • 29,285
  • 22
  • 112
  • 207

0 Answers0