Chapter 24: Swing Testing with jfcUnit


Overview

jfcUnit is a Swing testing framework built on top of JUnit. As we saw in Chapter 13, JUnit allows us to do unit testing of our application s individual classes to ensure that they are performing as designed. jfcUnit extends that functionality to Swing-based applications, allowing us to test our user interfaces as well as our application interfaces.

Currently it supplies support for:

  • Obtaining window and dialog handles.

  • Locating specific components inside of a window, including components inside of components (a component hierarchy).

  • Raising events on the found components, e.g. clicking a button, or typing text in a text field.

  • Handling testing of components in a thread-safe manner.

  • XML recording of events for playback testing.

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 application ”why not just test the classes that it uses? In order to properly ensure that your application 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 application 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.

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:

http://jfcunit.sourceforge.net/

end sidebar
 



Professional Java Tools for Extreme Programming
Professional Java Tools for Extreme Programming: Ant, XDoclet, JUnit, Cactus, and Maven (Programmer to Programmer)
ISBN: 0764556177
EAN: 2147483647
Year: 2003
Pages: 228

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net