Unit testing of GMF diagram editors and shortcuts with JUnit
A bit of background: My GMF diagramming plugin allows for elements to be provided as shortcuts in the model. I have extended the plugin to allow for automatically adding new shortcuts to the diagram editors, if they are connections of edges in the model.
I wanted a way to test the following things with JUnit:
- Diagram files can be loaded
- Model files can be initialised by going Right Click > Initialise new my_diagram
- The visual display of the diagram files (which nodes are displayed, etc)
- Model files with diagram partitioning can be opened and traversed
- Shortcut elements are displayed as shortcuts
- My custom shortcut-generation functionality
I can’t go into a tutorial for each of these individual elements, but I can provide the code that I used to implement all of these (they are all grouped together into a JUnit Test Suite for Eclipse):
- Diagram files can be loaded (method)
- Model files can be initialised (helper method)
- The visual display of the diagram files
- Model files with diagram partitioning can be opened and traversed
- Shortcut elements are displayed as shortcuts (method)
- My custom shortcut-generation functionality (the project as a whole)
I’m not sure if this is any help to anybody, but it’s probably a good reference. Perhaps in the future I can release a GMFUnit wrapper around JUnit.