5.2. Testing Lists Whose Order Is ImportantHere's the business rule for discount groups, our second example.
This description is not easy to follow, a situation that often arises with requirements documents. We'll see that the following examples in this chapter and in the next will help clarify what's really required. At this stage, we simply check that the current discount groups are stored in order, as expected, in the file. The fixture DiscountGroupOrderedList, a RowFixture, is named in the first row of Figure 5.7. The header row labels the five expected field values of each element in the list, from order to discount percent.
We have included a column order here to be explicit about the order of the elements in the file. (This value doesn't occur in the file, so it is added by the fixture.) Fit runs the table and compares the table rows with the elements of the list in the system under test. The report resulting from Figure 5.7 is shown in Figure 5.8. Figure 5.8. Report
Questions & Answers
Programmers The fixture code for the tests here is given in Section 23.2 on p. 197. Note For now, we have ignored how the discount groups are changed. We have simply tested that they are all as expected at a certain point in time. In Section 6.2 on p. 43, we show a sequence of tests that checks that additions to the discount groups are stored correctly. Note that we're not testing that the discount groups are being handled correctly when discounts are calculated in the software; other tests are needed to do that. For example, either of the "medium" discount groups may apply, but which takes priority? We take this up in Section 6.2 on p. 43. |