18.5. List TestsWe now focus on design ideas and smells that apply to list tests expressed with RowFixture, ArrayFixture, and SubsetFixture. 18.5.1. Smell: Too Many List ColumnsConsider the Fit table shown in Figure 18.15, which is checking that the count of items is correct. Several columns are irrelevant to this test, adding unecessary and distracting detail. We can improve this table by eliminating the irrelevant columns, as shown in Figure 18.16.
In general, if a Fit table for testing lists has many columns, consider whether all of them are relevant to the test. For example, you may decide to include just those columns that are expected to change or those that are expected to not change. 18.5.2. Smell: Too Many List RowsSuppose that we are interested only in the number of coffeee urns. Then the table in Figure 18.16, as discussed in Section 18.5.1, contains more detail than necessary. The SubsetFixture table shown in Figure 18.17 can then be used to focus on the number of that one rental item.
Another approach to reducing irrelevant detail is to select some of the elements of the list. For example, the test in Figure 18.18 uses an argument, Joanna, to focus on a single client's rentals, avoiding the need to list the rentals of all clients.
|