我正在开发一个 JavaFX(使用 TornadoFX)项目,我想在无头环境(Circle CI)中对其进行测试。
我已经尝试过这里写的内容,但它不起作用。无论我如何配置 TextFX,我总是得到
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
例外。如果我在我的计算机上运行测试,我可以看到弹出 JavaFX 窗口并且机器人点击屏幕上的内容。
这就是我的测试的样子:
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()
}
}
}
我也尝试从 gradle 设置无头模式,但它也不起作用:
junitPlatformTest {
jvmArgs "-Dheadless=true"
}
如果我将上述所有参数作为 jvm 参数传递,我仍然会看到弹出 JavaFX 窗口。