15.3 Dates
"We need an action that sets the date. Then we can control the time whenever we want," Sarah offered. After trying several action words, she suggested setting the date as shown in Figure 15.5.
Table 15.5. An Action to Set the Date
time is now |
2004/05/06 09:01 |
After Sarah added the time-change action to several tests, Emily suggested that she "put it at the end of the SetUp, as all tests will need date/time set." Sarah added that to Figure 15.1. She then changed the rental test in Figure 15.4 to become the test shown in Figure 15.6, having added in hours and days to the second table.
Figure 15.6 Test Rental with Dates
"Why not use an end date as well?" Don suggested. He changed the second table of the test, as shown in Figure 15.7.
Table 15.7. Revised Second Table of Test Rental with Dates
rentals for client |
Joanna |
||
rental item |
count |
start date |
end date |
cup |
100 |
2004/05/06 09:01 |
2004/05/20 09:01 |
Questions & Answers
-
It's easy to write the test, but making it work is not so easy.
Yes, that's true, as we'll see in Chapter 34. But the payback from doing so is immense, as we can then write automated tests that pick up errors soon after they're made.
In the medium term, having test support and higher quality in the software can make a huge difference in the speed at which changes can be made. And being able to communicate about what's needed, using Fit tests to express that, is also so valuable; it helps to focus the effort where it's needed.