Fit for Developing Software: Framework for Integrated Tests
14.2. Cash Rentals
To give us some background, Don took us through a few scenarios, using RentEz: A cash rental occurs when someone comes in to rent some party equipment, such as a coffee dispenser, for some time period. It's called "cash" if the client has not made a booking and will pay immediately rather than on account. A staff member at the rental company serves the client, recording the details, if necessary, as well as what the client wants to rent and for how long. A timed record is kept of what the client rented and when; that way, when the rental goods are returned, a check can be made as to whether the client owes more money or is due a refund of the deposit. "For a start, we've decided to ignore several issues and details," said Don. These included
Once it was clear that they were tackling a suitably sized problem, we left them to it for an hour or so. We returned to find them in the middle of an animated discussion about managing the tests for running totals for charges and deposit refunds. They had written out several tests on the whiteboard and on three large sheets of paper stuck on the wall. "We've got some questions for you, including the best way of handling the hourly and weekly rental rates for RentalItems." Emily had sketched three of the components of their system, as shown in Figure 14.1. "A Client may have several currently rented items. A Rental is an association between a Client and a RentalItem, with additional information, such as the number of RentalItems rented, the date/time the rental started, the period of the rental, and so on." Figure 14.1. The Three Components
"We've decided to keep the identification of Clients and RentalItems simple at this stage," said Emily, as shown by one of their tests in Figure 14.2. They had used some initial tables in Figure 14.2 to provide some Client and RentalItem data (see the Tip on p. 107). As Emily explained, the tables are as follows.
Three roles are identified in these tables: setup, action, and check. Tables filling these roles occur in most action-based tests, in that order. The first three setup tables were, more or less, included in all their tests. After discussion about the various tests they'd written, we all decided that several changes would be helpful, as we cover in the following sections.
Figure 14.2. Test Partial Returns
Tip A useful technique is to have a compact way of setting up the initial data to use in a test. If that data had to be entered through tables that drive the usual workflow, several problems would arise.
Yes, that does lead to a little more work for the programmers in creating extra fixtures that handle the setup. However, there are also benefits to this, as we'll see in Chapter 32.
|