UISpec4J: Java GUI testing made simple!

UISpec4J is an Open Source functional and/or unit testing library for Swing-based Java applications, built on top of the JUnit test harness.

If you are writing a Swing application, you will appreciate UISpec4J above all for its simplicity: UISpec4J's APIs are designed to hide as much as possible the complexity of Swing, resulting in easy to write and easy to read test scripts. This is especially true when comparing UISpec4J tests with those produced using Swing or low-level, event-based testing libraries.

Here is for example how a JTable content is tested with UISpec4J. This table:

can be checked using this test:

          
  public void testContacts() {
    Table contacts = getMainWindow().getTable();
    assertTrue(contacts.contentEquals(new Object[][]{
      {"John", "12", Boolean.FALSE},
      {"Sylvia", "43", Boolean.TRUE},
      {"Bill", "31", Boolean.FALSE}}));
   }
        

This code is shorter than what would be needed using the Swing APIs, but there is more: it checks the values actually displayed by the underlying JTable component, not just its internal model values. Achieving this with Swing would require checking the values computed by the renderers, resulting in several times as many lines of code.

Current release

The current release is 1.5 (see change log ).

You can retrieve it from our download page.

A java.net project

java.net member UISpec4J is hosted on java.net as a full fledged project of the JavaDesktop community. You can find our project page with CVS access, issue tracking, etc. at the following address: uispec4j.dev.java.net

Acknowledgements

We would like to thank JetBrains for providing us with licences for their excellent IDE, IntelliJ/IDEA. Intellij/IDEA
We would also like to thank Cenqua for providing us with licences for Clover, an excellent code coverage analysis tool. Clover