More Related Content
Similar to Test GEF Apps with SWTBot
Similar to Test GEF Apps with SWTBot (20)
Test GEF Apps with SWTBot
- 1. GEF Support in SWTBot
Use a bot to test your GEF and GMF based applications
Mariot Chauvin - mariot.chauvin@obeo.fr
Obeo (France)
1
- 2. GEF Support in SWTBot
Use a bot to test your GEF and GMF based applications
SWTBot presentation
Tool for UI and functional testing
Usable for SWT and Eclipse based applications
Consistent API
Wrappers for each SWT widget
Finders to retrieve contributions based on conditions
Matchers to write conditions in a expressive way
© Copyright 2009 Obeo. made available under the EPL v1.0 | Oct. 25th, 2009
- 3. GEF Support in SWTBot
Use a bot to test your GEF and GMF based applications
SWTBot test example
@Test
public void canCreateANewJavaProject() throws Exception {
bot.menu("File").menu("New").menu("Project...").click();
SWTBotShell shell = bot.shell("New Project");
shell.activate();
bot.tree().select("Java Project");
bot.button("Next >").click();
bot.textWithLabel("Project name:").setText("MyFirstProject");
bot.button("Finish").click();
}
© Copyright 2009 Obeo. made available under the EPL v1.0 | Oct. 25th, 2009
- 4. GEF Support in SWTBot
Use a bot to test your GEF and GMF based applications
GEF presentation
Framework for graphical editors with an MVC architecture
Lightweight layout and rendering 2D toolkit
MVC architecture agnostic of model representation
EditParts play the role of controller
Figures are the view instances
EditPolicies encapsulate the behavior
© Copyright 2009 Obeo. made available under the EPL v1.0 | Oct. 25th, 2009
- 5. GEF Support in SWTBot
Use a bot to test your GEF and GMF based applications
GEF based application example
© Copyright 2009 Obeo. made available under the EPL v1.0 | Oct. 25th, 2009
- 6. GEF Support in SWTBot
Use a bot to test your GEF and GMF based applications
GEF based applications testability
Delivering a product meaning ensure general good works and
end user features non regressions between releases. How to
achieve that ?
Manual tests
Time and resource consuming
Error prone
Automatic tests
Difficult to instantiate editPart and simulate user actions
Need to poll UISynchronizer to execute asynchronous runnables
Why do not extend SWTBot to support GEF ?
© Copyright 2009 Obeo. made available under the EPL v1.0 | Oct. 25th, 2009
- 7. GEF Support in SWTBot
Use a bot to test your GEF and GMF based applications
Quick demo
© Copyright 2009 Obeo. made available under the EPL v1.0 | Oct. 25th, 2009
- 8. GEF Support in SWTBot
Use a bot to test your GEF and GMF based applications
Available API
Create a node element
editor.activateTool(String name)
editor.mouseMoveLeftClick(int x, int y)
Create an edge element
editor.activateTool(String name)
editor.mouseMoveLeftClick(String editPartName)
editor.mouseMoveLeftClick(String editPartName)
© Copyright 2009 Obeo. made available under the EPL v1.0 | Oct. 25th, 2009
- 9. GEF Support in SWTBot
Use a bot to test your GEF and GMF based applications
Available API
Drag an element
editor.mouseDrag(String label, int x, int y)
Double-click on an element
editor.mouseMoveDoubleClick(int x, int y)
Direct edit on a element
editor.mouseMoveLeftClick(String label)
UIThreadRunnable.syncExec(new VoidResult() {
public void run() {
part.performRequest(request);
}
});
editor.directEditType(String text)
© Copyright 2009 Obeo. made available under the EPL v1.0 | Oct. 25th, 2009
- 10. GEF Support in SWTBot
Use a bot to test your GEF and GMF based applications
GMF based application demo
© Copyright 2009 Obeo. made available under the EPL v1.0 | Oct. 25th, 2009
- 11. GEF Support in SWTBot
Use a bot to test your GEF and GMF based applications
Could I use it to do more ?
Generate UI and its tests with acceleo
EEF is doing such a thing with SWT and JFace
One could extend GMF generation to do the same
Maintains documentation and tutorials up to date
Write a SWTBot test for each tutorial
Take a screenshot between each step
© Copyright 2009 Obeo. made available under the EPL v1.0 | Oct. 25th, 2009
- 12. GEF Support in SWTBot
Use a bot to test your GEF and GMF based applications
Project status and early adoption
Project status
First committed on a google code project
Contributed since to SWTBot
A new feature will be soon available on update site
API will be redesign to use more matchers
API will be enhanced (delete, zoom, modeling assistant)
Early adoption
Checkout the code from SWTBot repository
Open bugs and feature requests
API is provisional !
© Copyright 2009 Obeo. made available under the EPL v1.0 | Oct. 25th, 2009
- 13. GEF Support in SWTBot
Use a bot to test your GEF and GMF based applications
Thanks for your attention !
Further information : mariot.chauvin@obeo.fr
http://www.obeo.fr
http://www.eclipse.org/swtbot
http://wiki.eclipse.org/SWTBot
© Copyright 2009 Obeo. made available under the EPL v1.0 | Oct. 25th, 2009