Wednesday, November 18, 2009

Section 10.4.  Setup









10.4. Setup


We now switch to the second example in Chapter 6. The test in Figure 6.5 on p. 45 starts with a ColumnFixture table that enters data for the rest of the test; this table is shown again in Figure 10.4.


Figure 10.4. Setup Table Using ColumnFixture

DiscountGroupsEntry

future value

max balance

min purchase

discount %

add()

low

0.00

0.00

0

true

medium

0.00

500.00

5

true

medium

500.00

500.00

3

true

high

500.00

2000.00

10

true

high

1000.00

500.00

5

true



Such data entry at the start of a test is a common pattern, as we'll see in Part II. However, Figure 10.4 makes use of a ColumnFixture table, which is better suited to testing calculations.


We can eliminate the last column, which is not calculating anything, by using a SetUpFixture table, as shown in the second (set ups) table in Figure 10.5. This enters the discount group data that is held in the remainder of that table. The later tables in Figure 10.5 are discussed in the following sections.



Figure 10.5. Discount: Various Tables







Tip



FitNesse provides a similar fixture to SetUpFixture; this fixture is RowEntryFixture.




Programmers



The fixture code for the tests here is given in Section 28.7 on p. 239.





Questions & Answers


Q1:

When do you use SetUpFixture tables?


A1:

We usually use them to get the system under test into a suitable state so that we can test some business process. Often, this means entering appropriate data, which we'd prefer to not do through long-winded workflow with actions, as they hide the fundamentals of the test. We cover this topic once we start looking at larger sets of tests, in Chapter 14.


We can also use a SetUpFixture table when several actions of the same form are carried out in sequence in the main part of the test.











    No comments: