Question

While we try to set up as many unit tests as time allows for our applications, I always find the amount of UI-level tests lacking. There are many options out there, but I'm not sure what would be a good place to start.

What is your preferred unit testing tool for testing Swing applications? Why do you like it?

Was it helpful?

Solution

On our side, we use to test SWING GUI with FEST. This is an adapter on the classical swing robot, but it ease dramatically its use.

Combined with TestNG, We found it an easy way to simulate "human" actions trough the GUI.

OTHER TIPS

If your target application has custom components, I would definitely recommend Marathon to automate your tests.

I was given the task of automating an application with several extremely complicated custom components, written in-house from the ground up. I went through a review process that lasted two months, in which I made the decision on which test tool to use, from a list of close to 30 test tools that were available, both commercial and FOSS.

It was the only test tool that was able to successfully automate our particular custom components; where IBM's Rational Functional Tester, Microfocus' TestPartner, QF-Test, Abbot & FEST failed.

I have since been able to successfully integrate the tests with Cruise Control such that they run upon completing each build of the application.

A word of warning though:
1) it is rather rough around the edges in the way it handles JTables. I got around this by writing my own proxy class for them.
2) Does not support record/replay of drag-and-drop actions yet.

Consider Marathon (http://www.marathontesting.com/Home.html)--tests are written in Jython, so it's easy to write any sort of predicates based on object state.

I had the chance to play around with QF-TEST once. It is commercial, but offers a lot of functionality. Maybe you have a look at it: http://www.qftest.de/en/index.html

You can try to use Cucumber and Swinger for writing functional acceptance tests in plain english for Swing GUI applications. Swinger uses Netbeans' Jemmy library under the hood to drive the app.

Cucumber allows you to write tests like this:

 Scenario: Dialog manipulation
    Given the frame "SwingSet" is visible
      And the frame "SwingSet" is the container
    When I click the menu "File/About"
    Then I should see the dialog "About Swing!"
    Given the dialog "About Swing!" is the container
    When I click the button "OK"
    Then I should not see the dialog "About Swing!"

Take a look at this Swinger video demo to see it in action.

I can highly recommend QFTest. I have used it for my commercial product and it works very well with almost zero code (my app requires the use java client APIs for some things). It handles identification of swing components well, and is pretty tolerant of updates to your GUI - (resizing,repositioning and adding components does not break existing tests). I have done major updates to functionality and have my tests still work.

Its expensive, but I think it will pay itself off in a couple of months.

Before QFTest I tried:

1) Automatedqa - good tool, but windows centric and does not understand Swing. Similar to Quick test Pro.

2)UISpec4J - After devoting a solid 50 hour week to this, I had issues with fragility and the arcane java code it produced. Using it was just too arduous - trying to debug/update hundreds of lines of java performing a sequence of a dozen GUI operations just did not work for my brain. I ended up avoiding writing tests because it much more complicated than actually writing the app itself!

I like Jemmy, the library written to test Netbeans.

Not an answer, but a refining.

Record-and-playback is the wrong thing to want. Teams need the ability to write tests before the code has been written. Otherwise, the coders finish their work and wait around while the testers scramble to record tests (interrupted by fixes when they spot issues).

In a BDD/TDD/ATDD kind of setup, you really need some kind of tool that allows you to script tests for code that hasn't been written yet, specifying UI element names and the like.

Are there tools that work for non-waterfall testing?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top