After reviewing several tools for writing UI tests for Eclipse based products, I finally settled down on SWTBot. Even after being a long time Eclipse plugin developer, I always found that I lacked a good tool for testing UI. I kept as much business logic code as possible away from UI code and wrote regular JUnit tests for that. But invariably, I ended up in situations where it made a lot of sense to write UI tests. What drove me towards SWTBot was the simplicity in writing tests, and also their ongoing effort in providing support for GEF (Graphical Editing Framework). Not to say that other tools do not provide nice features. I have heard that Window Tester from Instantiations is also good and provide good support. But SWTBot provided the quick start I needed to get some tests writting for the UI (ofcourse being an Eclipse project, and having an EPL license helps! ).
SWTBot is not part of the Galileo release train, but you can still use their plugins with Galileo (and that still qualifies my article for Eclipse Blogathon, I hope!). SWTBot is still an incubation project, and their support for GEF is currently hosted under Google Code. But even at this early stage, SWTBot is quite functional, and shows promise for becoming a robust test tool for Eclipse plugin and RCP developers.
SWTBot is launched similar to how a JUnit Plugin test is launched, except that an SWTBot launch runs in a non-UI thread. SWTBot also provides options to run in a headless mode, and an ant task to integrate for continuous testing. Writing test code with SWTBot is simple enough. The following code snippet opens the Import dialog to import projects into a workspace.
workbenchBot.tree().select(“General”).expandNode(“General”).select(“Existing Projects into Workspace”);
As you can see, the code is very readable and relatively easy to write. SWTBot lacks a Recorder (apparently there is one, but it is not actively maintained). In my opinion, a Recorder is useful only initially to get the hang of things, but once you start writing reusuable test modules, a Recorder loses much of its value. So I do not see it to be a big disadvantage, though having a recorder wouldn’t hurt.
If you are interested in trying out SWTBot, here are some resources to get you started:
Eclipse UI Test Tools Comparison: http://wiki.eclipse.org/Automated_Testing#UI_tests
SWTBot for GEF: http://code.google.com/p/swtbot4gef/