Section 18.5. List Tests


18.5. List Tests

We 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 Columns

Consider 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.

Figure 18.15. Many List Rows

rental items list

name

count

hourly rate

daily rate

weekly rate

deposit

coffee urn

10

1.50

12.00

60.00

50.00

table

20

6.00

48.00

200.00

80.00

coffee pot

20

1.50

12.00

60.00

0.00

chair

20

6.00

48.00

200.00

0.00


Figure 18.16. Fewer Columns

rental items list

name

count

coffee urn

10

table

20

coffee pot

20

chair

20


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 Rows

Suppose 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.

Figure 18.17. Fewer Rows with SubsetFixture

rental item subset

name

count

coffee urn

10


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.

Figure 18.18. Fewer Rows, Using Arguments

rentals for client

Joanna

rental item

count

start date

end date

cup

100

2004/05/06 09:01

2004/05/20 09:01




    Fit for Developing Software. Framework for Integrated Tests
    Fit for Developing Software: Framework for Integrated Tests
    ISBN: 0321269349
    EAN: 2147483647
    Year: 2005
    Pages: 331

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net