Testing with TestFx on travis-ci headful vs headless

772 views
Skip to first unread message

rohit vaidya

unread,
Jul 28, 2015, 3:34:24 AM7/28/15
to TestFX
Hello Experts, 
I am trying to test my JavaFX application on travis-ci with TestFX. I am not going for headless(travis-ci) because the monocle dependency always fails for me.
Hence I went for a headful test. However the test fails when I try to clickOn a button in a dialog box. 

Here is my travis yml file and here is my test. This test fails if I uncomment the clickOn("Cancel");. However this test works perfectly fine on a desktop. 

Locally I cannot run using monocle headless if I don't copy the monocle custom build jar on my machine to /jre/lib/ext folder. It works fine after copy it to jre/lib/extensions
I don't have this luxury on Travis Docker machine to update the jre jars. 

Which testing is better headful or headless if you are deploying on a ci platform like travis?
If anyone has faced this problem before please comment. 
Thanks, 
Rohit Vaidya

Oddbjørn Kvalsund

unread,
Jul 30, 2015, 4:25:22 AM7/30/15
to rohit vaidya, TestFX
What exception/error do you get?

We run our TestFX-tests on Jenkins both headless with Monocle and "headful" with Xvfb. When running headless with Monocle we have the jars published to our local Maven repository. See below a screenshot of the relevant part of our Jenkins-setup for Xvfb. Not all of these settings may apply for you.




Regards,
Oddbjørn Kvalsund

--
You received this message because you are subscribed to the Google Groups "TestFX" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testfx-discus...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

rohit vaidya

unread,
Jul 30, 2015, 7:24:47 AM7/30/15
to TestFX, oddbjorn...@gmail.com
Hi Oddbjørn Kvalsund,
Thanks for responding. 

1. I have to copy the Monocle jar to jre/lib/ext for it to take effect on local install. Otherwise I get the following error while running headless locally. 
 java.lang.ClassNotFoundException: com.sun.glass.ui.monocle.MonoclePlatformFactory. I get a similar error on Travis ci as well. 
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at com.sun.glass.ui.PlatformFactory.getPlatformFactory(PlatformFactory.java:42)

    You indicated in your reply you have published your jar locally in maven repository. Can you point me to some examples ? 
 
2. Since I wasn't able to run the tests headless I tried the headful approach. But this fails while trying to click buttons on Dialog Boxes and fails with the following exception. This works on Desktop!!! but not on Travis 
org.testfx.api.FxRobotException: the query "Cancel" returned no nodes.
at org.testfx.api.FxRobot.queryFirstVisibleNode(FxRobot.java:993)
at org.testfx.api.FxRobot.pointOfVisibleNode(FxRobot.java:962)
at org.testfx.api.FxRobot.clickOn(FxRobot.java:574)
at GitFxAppTest.launchApplication(GitFxAppTest.java:52)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:78)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:212)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:68)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)

Appreciate your help in resolving this. 
Regards, 
Rohit Vaidya

Oddbjørn Kvalsund

unread,
Aug 3, 2015, 3:41:21 AM8/3/15
to rohit vaidya, TestFX
Hi,

My apologies, we are in fact appending a directory ("lib/ext") containing the Monocle jar to the extension classpath using "-Djava.ext.dirs" in our Gradle-configuration:

test {
    doFirst {
        allJvmArgs = allJvmArgs.collect { String arg -> // This was the only way to override java.ext.dirs
            arg.startsWith("-Djava.ext.dirs") ? "${arg}${java.io.File.pathSeparator}${rootProject.file('lib/ext')}" : arg;
        }
    }
}

What build tool are you using? Perhaps you could try a similar approach?

Regards,
Oddbjørn Kvalsund
--
Oddbjørn Kvalsund

rohit vaidya

unread,
Aug 3, 2015, 5:17:11 AM8/3/15
to TestFX, rohi...@gmail.com
Hi Oddbjørn Kvalsund, 
I am using maven. Let me try your solution with maven.

Thanks, 
Rohit Vaidya. 
Reply all
Reply to author
Forward
0 new messages