how to test view in GEF MVC [message #1770640] |
Tue, 15 August 2017 09:57  |
Eclipse User |
|
|
|
The graphical views are controlled by part in GEF MVC. How could we test view such as its layout and interaction? How could we know the visual elements are placed at the correct position? Is there anything in GEF we can apply for testing? Thank you.
|
|
|
Re: how to test view in GEF MVC [message #1770646 is a reply to message #1770640] |
Tue, 15 August 2017 10:28   |
Eclipse User |
|
|
|
Hi Shenwei,
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 [1] 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 [2] 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 [3].
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.
[1] https://github.com/eclipse/gef/blob/master/org.eclipse.gef.mvc.tests.fx/src/org/eclipse/gef/mvc/tests/fx/rules/FXApplicationThreadRule.java
[2] https://github.com/eclipse/gef/blob/master/org.eclipse.gef.mvc.tests.fx/src/org/eclipse/gef/mvc/tests/fx/rules/FXNonApplicationThreadRule.java
[3] https://github.com/eclipse/gef/blob/master/org.eclipse.gef.mvc.tests.fx/src/org/eclipse/gef/mvc/tests/fx/BendConnectionPolicyTests.java
Best regards,
Matthias
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03142 seconds