Struggling with this...

102 views
Skip to first unread message

Mike Rodent

unread,
Oct 19, 2016, 2:39:20 PM10/19/16
to TestFX
First, thanks to all behind TestFX. 

I'm in the process of switching over to JavaFX, and from a testing standpoint have been a bit stumped: using Swing it was possible to go without a GUI testing framework, simply by using a combination of `EventQueue.invokeAndWait` and `Robot` in your test methods.  But if it is possible to do without a framework in JavaFX I haven't found it.

I'm a little perplexed about lack of tutorials and lack of properly Javadoc documentation with TestFX, though.  On this page I did manage to get that example test working... but I don't understand the business about the different suggestions for the Gradle file dependencies.  In the end I just used Maven Central, with:

    testCompile "org.testfx:testfx-core:4.0.+"
    testCompile "org.testfx:testfx-junit:4.0.+"

Also, what to make of the fact that all the version 4s (4.0.1 to 4.0.4) at the time of writing are in Alpha, despite the fact that it appears to have been around since 2014?  Much of the documentation has the annotation '@Unstable(reason="is missing apidocs")', which somewhat undermines confidence. 

It'd be great if someone could put the thing on a more friendly footing for new users...

Oddbjørn Kvalsund

unread,
Oct 20, 2016, 2:59:48 AM10/20/16
to Mike Rodent, TestFX
Hi Mike,

I agree; documentation on headless testing with TestFX is a bit sparse to say the least. The magic keyword you are looking for is "Monocle". Have a look at this StackOverflow post to get started: http://stackoverflow.com/questions/27403410/headless-testing-with-javafx-and-testfx

Regards,
Oddbjørn

--
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-discuss+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Oddbjørn Kvalsund

Benjamin Gudehus

unread,
Nov 2, 2016, 11:59:23 AM11/2/16
to Oddbjørn Kvalsund, Mike Rodent, TestFX
Hi Mike (again),

>But if it is possible to do without a framework in JavaFX I haven't found it.

This is actually an interesting idea. A minimal API for testing JavaFX applications could be:
  • static void Platform.startup(Runnable) to initialize the JavaFX toolkit (i.e. Glass windowing toolkit). In JavaFX 8 we need to launch an Application to initialize the toolkit. JavaFX 9 will provide a method [1] (also note the Javadocs).
  • static void Platform.runLater(Runnable) to run code within the JavaFX thread (i.e. JavaFX application thread). This API is available in both JavaFX 8 and 9.
  • static void Platform.runAndWait(Runnable) to run code within the JavaFX thread and wait until it finished. This API is in the source code in both JavaFX 8 and 9, but unavailable behind uncommented code (//).
  • class Robot with moveMouse(), pressMouseButton(), releaseMouseButton(), scrollMouseWheel(), pressKeyboardKey(), releaseKeyboardKey(). TestFX uses the AWT robot and translates JavaFX objects (like KeyCode, MouseButton) to AWT robot specific objects. There is a GlassRobot, which however behaves differently. The AWT and Glass robot are both missing functionaliity like typeKeyboardKey(), which allows Unicode characters, and touch events. It is possible to send these events using Event.fireEvent() [2].

Reply all
Reply to author
Forward
0 new messages