我正在使用JavaFX(使用TornadoFX)项目,我想在无头环境(Circle CI)中测试它。
我已经尝试了here写的内容,但它不起作用。无论我如何配置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窗口。