Question

What options are there for building automated tests for GUIs written in Java Swing?

I'd like to test some GUIs which have been written using the NetBeans Swing GUI Builder, so something that works without requiring special tampering of the code under test would be ideal.

Was it helpful?

Solution

Recently I came across FEST which seemed promising, except that the developer announced in 2012 that development would not continue.

AssertJ is a fork of FEST that is working very well for me. It is actively maintained (at time of writing), supports Java 8, has assertions for a few popular libraries such as Guava and Joda Time, and is very well documented. It is also free and open.

OTHER TIPS

I'm currently using FEST. It works with JUnit and will also take screenshots of failed tests.

It has default component hunting methods which look for the name of the component being tested (which need to be set manually), but you can also generate the testers for a given component by passing it the component.

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.

We are considering jemmy to automate some of the GUI testing. Looks promising.

I use java.awt.Robot. Is not nice, is not easy but works every time.

Pros:

  • You are in control
  • Very fast
  • Build your own FWK
  • Portable
  • No external dependencies

Cons:

  • No nice GUI to build test
  • You have to leave the GUI alone while you test
  • Build your own FWK
  • Difficult to change test code and create your first harness

Now if you have the budget I would go for LoadRunner. Best in class.

(Disclosure: relationship to the company that owns LR, but I worked with LR before the relationship)

I haven't used it personally, but SwingUnit looks quite good. You can use it with jUnit, and it isn't based on "location of components" (i.e. x and y co-ordinates).

The only thing you may have to do with the NetBeans GUI Builder is set unique names for your components.

We're using QF-Test and are quite satisfied.

UISpec4J is pretty simple, unbloated and extensible. It fits my purposes better than FEST.

Sikuli: a GUI-tester using screenshots http://sikuli.org/

You can use Marathon : "Marathon Integrated Testing Environment, MarathonITE, is an affordable, easy-to-use and cross-platform Java/Swing™ GUI Test automation framework. You can use MarathonITE‘s inbuilt script recorder to create clean, readable test scripts either in Python or Ruby. Advanced features like extract-method refactoring, create-datadriven-tests and objectmap editing allows you to create maintainable, resilient test suites."

You could try ReTest, which is a novel tool that implements an innovative approach to functional regression testing and combines it with ai-based monkey testing. It is about to become open source as well...

Disclaimer: I am one of the founders of the company behind ReTest.

For those with an adventurous mind, there is gooey https://github.com/robertoaflores/Gooey a (very basic and under-development) programmatic testing tool for swing applications.

You can user sikuli or Automa for testing your GUI part, these are well documented and tested tools

Just did some quick scans. Squish was the most promising. Not for free though

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