5.1. Testing Lists Whose Order Is UnimportantHere's the business rule for chat room occupants, our first example.
This business rule is related to the one in Section 4.2 on p. 26. A Fit table to test that the current occupants of the chat room are as expected, such as after the actions of Figure 4.6 on p. 27, is shown in Figure 5.1.
The first row names the fixture OccupantList, which determines from the system under test the list that is to be tested against the table rows after the second row. In this book, we use the convention that all fixtures related to testing lists include List in their names. The second, header row of the Fit table in Figure 5.1 labels the columns with the two expected[1] field names for the elements of the list. Two further rows are for the two expected occupants of the chat room. The order of these two rows does not need to be the same as their actual order in the system under test.
When Fit runs the tests in Figure 5.1, the report shown in Figure 5.2 results, with both rows correct and marked with green. This tells us that two elements are in the collection and that they match the rows given in the table. Figure 5.2. Fit Report for TestOccupants
The report in Figure 5.3 (see also Plate 3) results from a different test, in which the expected rows don't match that actual collection. As usual, unexpected values are marked with red. Figure 5.3. Fit Report for TestOccupants
Questions & Answers
Programmers The fixture code for the tests here is given in Section 23.1 on p. 195. |