Swing Testing with jfcUnit


jfcUnit is a Swing testing framework built on top of JUnit. As we saw in , JUnit allows us to do unit testing of our app’s individual classes to ensure that they are performing as designed. jfcUnit extends that functionality to Swing-based apps, allowing us to test our user interfaces as well as our app interfaces. Currently it supplies support for:

The version of jfcUnit that we will be covering in this chapter is 2.0.2. Earlier versions do not have the XML support for recording and playback that this version has. So, why would you want to test your Swing app—why not just test the classes that it uses? In order to properly ensure that your app functions properly under all circumstances, you should perform as many tests as possible. By providing a Swing test framework, the makers of jfcUnit have made it possible to not only test the underlying classes but also the user interface. By testing the user interface you ensure that your users will always see what they should be seeing, and that your app receives the proper input to its underlying classes. Testing with jfcUnit is rather straightforward. Because jfcUnit offers an extension of the normal JUnit test case, you can simply integrate it with your normal test cases as either its own test suite or as a member of an existing suite. The primary difficulty that you may encounter when using a tool like jfcUnit is ensuring that you are finding the correct component for testing. We will show you how to do this in the next section.

Java Start Sidebar
Where to Get jfcUnit

JfcUnit is an open source project hosted at Sourceforge and is available under the GNU Library or Lesser GPL at:

Java End Sidebar