Just in case you aren’t familiar with JRubyFX, checkout our introduction to JRubyFX.
Automated testing is a must. Automated testing with JRubyFX was a little difficult to get going, but now we have an ever increasing number of integration tests and things have been VERY stable for some time now. At this point, I’m comfortable sharing what we have and confident that others can reproduce this.
Automaton is a GUI testing framework for Swing and JavaFX applications. I chose automaton because… well I got it to work with little effort. I just downloaded their “fat jar” and
required it and we were up and running. Automaton does not appear to be the most popular testing framework, so in the future we may migrate to something like testfx or jemmy. But for now, it works for us.
Automaton takes over your mouse and keyboard to perform actions as if a user were doing the same. This is different than your typical selenium tests that “click” or “type” without taking control of the keyboard mouse. This was a little annoying before we moved to Docker as we had to “watch” our tests every time they ran locally. If you fight Automaton, it will just keep on trying to move the mouse until you stop messing with it. We also have a post about our migration to Docker.
Some code was omitted for brevity, but this should get you started:
This gives you an FXer which has an API similar to selenium and other web-related test frameworks. This includes retrieving elements in the UI and interacting with them. The test attempts to:
ListViewelement that holds the information for Brakeman warnings.
#represents the ID).
JRubyFX::Application::Platform.exitis required else your test will hang indefinitely.