32.1. IntroductionIn Chapter 14, Don, Emily, and Sarah started to develop several Fit tables for testing workflow. Here, we see how Emily proceeded to write fixtures that connect those Fit tables to the system under test, even though those tables were developed further in Chapter 15. Unfortunately, the RentEz software architecture is structured poorly; the GUI code and the business logicthe presentation and domain layersare tangled.[1] So there is no clear domain layer with an API that can be tested directly. Emily considered several approaches, with prompting, to tackle this difficulty.
Note Tests in many scripting languages can be recorded when the system is used and can be played back at another time. Unfortunately, the resulting test scripts are usually far too detailed and are difficult to alter and maintain. Some suffer from depending on the position of GUI components on the screen, so are vulnerable to simple layout changes. The company had used various test scripting systems but was not inclined to continue with them. After much discussion, Emily decided to proceed with the last option. To get started on this approach, she decided to try it out on a simple system. The RentEz GUI is written with Java Swing, so a way was needed to test through that interface. Fortunately, there are several open source tools for automating unit testing of Swing-based GUI systems. See the following Note for details of some of these tools. After exploring the various tool possibilities and seeking advice, Emily decided to use jfcunit. This tool is intended for unit testing, based on JUnit, so Emily used a FitLibrary class that made it easy to use from Fit fixtures. Note Following are several open source frameworks for unit testing Java Swing-based GUI systems:[a]
Several of these frameworks also have support for scripting tests in various forms, including using XML. Similar frameworks are available for other GUI systems. Such systems have support for accessing the required component from the GUI and operating on it. Access to a component may be made in various ways, including its name property and its type. |