Using TestFX components for jmh benchmarking

57 views
Skip to first unread message

Zsolt Kúti

unread,
Mar 15, 2018, 10:01:08 AM3/15/18
to TestFX
Hi,

To test our non-functional requirements we want to benchmark some rendering speed. For this we use jmh gradle plugin and the following testfx components.
jmh "org.testfx:openjfx-monocle:8u76-b04"
jmh "org.testfx:testfx-core:4.0.12-alpha"

Here is the concept how it is done:

private MyApplication application;

@Setup
public void setup() throws TimeoutException {
new JFXPanel();
FxToolkit.registerPrimaryStage();
application = (MyApp)FxToolkit.setupApplication(MyApp.class);
FxToolkit.showStage();
}

@TearDown
public void tearDown() throws Exception {
application.stop();
}

@Benchmark
public void render() {
<do something appropriate with app to provoke rendering>
}


This works fine while running it locally. As soon I put it on Jenkins it blows up at the setup() with:
java.lang.UnsupportedOperationException: Unable to open DISPLAY
	at com.sun.glass.ui.gtk.GtkApplication.<init>(GtkApplication.java:68)
	at com.sun.glass.ui.gtk.GtkPlatformFactory.createApplication(GtkPlatformFactory.java:41)
	at com.sun.glass.ui.Application.run(Application.java:146)
	at com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:257)
	at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:211)
	at javafx.embed.swing.JFXPanel.initFx(JFXPanel.java:215)


However, the example Spock test taken from TestFX github page runs without problem on Jenkins.


This makes me think some initialization that TestFX does with normal usage is missing here.
I tried passing below jvm arguments to jmh forks, to no avail:
-Djava.awt.headless=true -Dtestfx.robot=glass -Dtestfx.headless=true -Dprism.order=sw -Dprism.text=t2k -Dtestfx.setup.timeout=2500 -Dglass.platform=Monocle -Dmonocle.platform=Headless

Any idea how to overcome this appreciated!

Zsolt
Reply all
Reply to author
Forward
0 new messages