Problem when trying do gui tests in jenkins

I have a small h=java project which uses javaFX, junit5 et gradle, the tests run fine in eplipse, the test run fine using gradle in the local mac, when trying to run the tests in jenkins using the same gradle file tests break when the test using the gui are executed, there are exceptions.

Here is the project

Here are the eclipse project zip

Started by user Ruben Gonzalez-Rubio Building in workspace /var/local/jenkins/.jenkins/workspace/jPGtestFX [WS-CLEANUP] Deleting project workspace… [WS-CLEANUP] Deferred wipeout is used… [WS-CLEANUP] Done Checking out a fresh workspace because there’s no workspace at /var/local/jenkins/.jenkins/workspace/jPGtestFX Cleaning local Directory . Checking out svn+ssh://gonr1001@svn.gel.usherbrooke.ca/grp/svn/devJava/projectJGtestFX/trunk/jPGtestFX at revision ‘2019-01-23T12:14:48.164 -0500’ --quiet Using sole credentials gonr1001/****** (dev) in realm ?gonr1001@svn+ssh://svn.gel.usherbrooke.ca? Using sole credentials gonr1001/****** (dev) in realm ?gonr1001@svn+ssh://svn.gel.usherbrooke.ca? At revision 38 No changes for svn+ssh://gonr1001@svn.gel.usherbrooke.ca/grp/svn/devJava/projectJGtestFX/trunk/jPGtestFX since the previous build [Gradle] - Launching build. [jPGtestFX] $ /var/local/jenkins/.jenkins/tools/hudson.plugins.gradle.GradleInstallation/default_4.10/bin/gradle -Pheadless=true test Starting a Gradle Daemon (subsequent builds will be faster) > Task :compileJava > Task :processResources > Task :classes > Task :compileTestJava > Task :processTestResources NO-SOURCE > Task :testClasses > Task :test sample.MainTest > testEnglishInput() FAILED java.lang.RuntimeException Caused by: java.lang.RuntimeException sample.models.CalculatorTests > addsTwoNumbers() PASSED sample.models.CalculatorTests > add(int, int, int)[1] PASSED sample.models.CalculatorTests > add(int, int, int)[2] PASSED sample.models.CalculatorTests > add(int, int, int)[3] PASSED sample.models.CalculatorTests > add(int, int, int)[4] PASSED tests.ClickApplicationTest > should_click_on_button() FAILED java.lang.RuntimeException Caused by: java.lang.RuntimeException tests.ClickApplicationTest > should_contain_button() FAILED java.lang.RuntimeException Caused by: java.lang.RuntimeException 8 tests completed, 3 failed > Task :test FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ‘:test’. > There were failing tests. See the report at: file:///var/local/jenkins/.jenkins/workspace/jPGtestFX/build/reports/tests/test/index.html * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. * Get more help at https://help.gradle.org BUILD FAILED in 15s 4 actionable tasks: 4 executed Build step ‘Invoke Gradle script’ changed build result to FAILURE Build step ‘Invoke Gradle script’ marked build as failure Finished: FAILURE

Page generated: Jan 23, 2019 12:15:16 PM ESTREST APIJenkins ver. 2.161

Could you give an example of what kinds of exceptions you were seeing? Could it be because the Jenkins environment doesn’t have a window manager for the GUI to use?

It’s likely that your Jenkins server is headless. You could get the same failure locally by setting

System.setProperty("java.awt.headless", "true")

You will likely want to use TestFX & Monocle for headless testing of JavaFX

Hi Thanks for the Answer

The Jenkins server was updated to the last version, the gradle version indicated is 4.1, in my computer (a Mac) is 5.1.

So I send you the output on Jenkins.

And the files that compose the program, the program intention is to be sur that junit5 test works fine junit tests and testFX tests.

Thanks for your help.

Ruben

The program works fine in a mac and in a PC, inside eclipse and outside with gradle.

(Attachment ATT00001.htm is missing)

(Attachment ClickApplication.java is missing)

(Attachment ATT00002.htm is missing)

(Attachment Main.java is missing)

(Attachment ATT00003.htm is missing)

(Attachment CalculatorTests.java is missing)

(Attachment ATT00004.htm is missing)

(Attachment build.gradle is missing)

(Attachment ATT00005.htm is missing)

(Attachment Controller.java is missing)

(Attachment ATT00006.htm is missing)

(Attachment MainTest.java is missing)

(Attachment ATT00007.htm is missing)

(Attachment sample.fxml is missing)

(Attachment ATT00008.htm is missing)

(Attachment Calculator.java is missing)

(Attachment ATT00009.htm is missing)

Hi Thanks for the Answer

The Jenkins server was updated to the last version, the gradle version indicated is 4.1, in my computer (a Mac) is 5.1.

So I send you the output on Jenkins.

And the files that compose the program, the program intention is to be sur that junit5 test works fine junit tests and testFX tests.

The message from Jenkins is at the end of the mail.

Thanks for your help.

Ruben

The program works fine in a mac and in a PC, inside eclipse and outside with gradle.

(Attachment ClickApplication.java is missing)

(Attachment ATT00001.htm is missing)

(Attachment Main.java is missing)

(Attachment ATT00002.htm is missing)

(Attachment CalculatorTests.java is missing)

(Attachment ATT00003.htm is missing)

(Attachment build.gradle is missing)

(Attachment ATT00004.htm is missing)

(Attachment Controller.java is missing)

(Attachment ATT00005.htm is missing)

(Attachment MainTest.java is missing)

(Attachment ATT00006.htm is missing)

(Attachment sample.fxml is missing)

(Attachment ATT00007.htm is missing)

(Attachment Calculator.java is missing)

(Attachment ATT00008.htm is missing)

Do you mean that is not possible to run gui tests (testFX) using jenkins?

Ruben

Yes I need to use testFX Monocle can be changed, if you have an alterative.

Monocle is the implementation of the windowing component of JavaFX (Glass) which will work on a headless server (eg jenkins). I think you’ll need to use Monocle to test JavaFX on your Jenkins server.

A quick read of the Monocle docs discuss
-Dglass.platform=Monocle -Dmonocle.platform=Headless -Dprism.order=sw

I suggest you do some further reading on using Monocle with JavaFX on a headless server