|Re: how to test view in GEF MVC [message #1770646 is a reply to message #1770640]
||Tue, 15 August 2017 14:28
|| Matthias Wienand
Registered: March 2015
the default interactions provided by GEF are tested, too. For this purpose, we implemented two JUnit test rules that initialize the JavaFX toolkit:
- The FXApplicationThreadRule  ensures that the test code is executed on the JavaFX application thread. Therefore, the scene graph can be accessed directly, without having to spawn runnables on the application thread. However, interactions (firing events, waiting for processing, etc.) needs to be done manually using FXApplicationThreadRule.
- The FXNonApplicationThreadRule  ensures that the test code is executed on a thread other than the JavaFX application thread. It provides a number of utility methods that can be used to perform interactions within the JavaFX application thread similar to the AWT Robot. The JavaFX events for mouse/keyboard interaction are synthesized, instead of trying to make the system send the events. The FXNonApplicationThreadRule ensures that the events are completely processed before continuing test execution. Therefore, I would suggest using FXNonApplicationThreadRule for testing interactions. For a usage example, you can take a look at BendConnectionPolicyTests .
One thing you will probably want to do different than GEF is using a mocking framework to reduce boilerplate code. For GEF, the different options still need to be evaluated and the test code needs to be refactored once a decision is made (for using a specific mocking framework), i.e. the many inner classes should not be taken as a deterrent.
Powered by FUDForum
. Page generated in 0.03710 seconds