niedziela, 31 maja 2009

Automate your GUI for free! With Marathon

Some time ago I was struggling with automation of GUI testing. Problem wasn't typical. Regular flow involved loading our (web) service into external (Java) tool emulating real mobile device, browsing fixed set of pages and taking screenshots. Next those screens were examined for rendering defects.

Obviously, this was great target for automation. This seemed as a hard task, as external testing tool didn't have any API or interface to connect my custom code. As a surprise, I found great (and LGPL) tool - Marathon (

First of all, Marathon supports recording scripts (clicked in app GUI!) that could be saved and replayed. Of course this feature isn't perfect, as Java GUIs tends to use multiple frameworks and custom Swing components. But this can be easily fixed with Jython - main language of Marathon scripts. Integrating Java and Python, it enables user to write custom Java code executed within tested application's Virtual Machine. Wow! This gives developer almost unlimited possibilities. Injecting AWT events, emulating mouse clicks and activating isolated Swing components is easy and straight-forward. Still, without application's sources determining applicable components can be difficult. Thankfully, Marathon offers drop-in console that can be used to freeze application and review it's component tree.

To recap, usage of Marathon helped me reduce time necessary for taking service screenshots by 80%. Also, tool proved to be very potent - from automating GUI to testing Swing applications. As every free tool, it has some issues, but advantages of speeding up tedious tasks are very rewarding.