I’ve done my fare share of developing Swing apps in my java years. Perhaps 40% of UI development in my 8 years of java experience is done in Swing. Now that’s a quite a big percentage these days, when most of my colleagues have never done any Swing and their UI development is mostly done to web. Since the industry is concentrated to the web, naturally most of the tools (for example testing) are concentrated to web as well.
I believe that integration tests are perhaps the most valuable tests that are written (Acceptance tests excluded, but you create acceptance tests using these tools), so I share my experiences from two very different open source testing tools for Swing. One is called the FEST-Swing, and the other is Marathon.
FEST-Swing
FEST-Swing is a Java API for, which is based on looking up components and making assertions on them. The API is a DSLish ‘fluent API’, which makes writing the tests somewhat pleasant. It can be used with either JUnit or TestNG so it doesn’t lock you in one unit testing framework, and the best part of the project is that it is active (last update was on May 19 2008). For example, I used FEST-Swing for testing my SCJD assignment, and it proved to be a good tool for the purpose – no problems in writing the tests, and it was quite easy to test all the scenarios. I’m not sure how it responds to more complicated UI’s, but I’m ready to give it a try in other projects as well. Very promising indeed.
Marathon
The project was initially started by the ThoughtWorks developers, so I thought there might by something to it and I decided to give it a try. The framework is based on capturing user interactions and recording them as Python scripts. Of course you can edit these recorded scripts later on using any text editor, because the scripts are valid Python, not some proprietary format. I tried this on one quite complicated (lot’s of user interface logic and decision making) project and I ran into problems. The scripts recorded by the recorder all required some manual editing before I could re-run them from the Python file.
Frankenstein
Sidu Ponnappa sent a comment to my “about”-page concerning another open source framework, the Frankenstein. It is hosted at openqa.com, the same site that hosts Selenium. Like Marathon, this is also started in the ThoughtWroks labs. After a quick try Frankenstein is a clearly on a very early stage of it’s development. For example, the documentation is extremely lightweight, with practically no examples.
The framework allows you to record your UI actions, which are then saved to Ruby scripts. After a few try and errors I managed to record some actions and run the saved Ruby scripts after minor changes to the scripts. What I liked about this one was the simplicity of the recorder, and the possibilities that the Ruby driver brings to testing the UI’s..
Filed under: Java EE, Software development, Uncategorized | Tagged: Swing, testing