Running JavaFx test on headless CI enviroment with Monocle fails

652 Views Asked by At

I'm trying to write test on for JavaFx, which will work on headless CI. When I run my tests in normal way, all tests work properly, but if I run them on CI they don't. It seems that FxRobot doesn't click some element in proper way, because I get error like:

Expected: Buttton is disabled
     but: was <Button[id=restart, styleClass=button_restart]'RESTART'>

As I said, all of those tests pass locally. I run test with command:

mvn test -Dtestfx.robot=glass -Dtestfx.headless=true -Dglass.platform=Monocle -Dmonocle.platform=Headless -Dprism.order=sw -Dprism.text=t2k -Dprism.verbose=true 

I m using Java 11, TestFx 4

1

There are 1 best solutions below

2
AdminOfThis On

If you run CI on a linux headless server, you need to run it with the xvfb tool, which simulates a graphical interface.

For specific instructions on how to set it up, search the docs of your CI provider for "xvfb", or provide your specific CI tool (Travis-CI, Circle-CI, etc).