28.7. SetupAs we saw in Section 10.4 on p. 76, a SetUpFixture table may be used for setting up the data at the start of a test. This example is shown again in the second table of Figure 28.6. Figure 28.6. Discount: Various Tables
The fixture class Discounts, a DoFixture, is shown in Listing 28.8. The method setUp() is called for the action set up in the first row of the second table. This returns a fixture object, of class SetUpDiscounts, which is used to interpret the rest of the table. The fixture class SetUpDiscounts is a SetUpFixture, as shown in Listing 28.9. SetUpFixture reads the labels in the second row of the table and combines them into the name of a method. The "%" in the fourth label is converted into "percent", as defined by extended camel casing (see the Note on the next page). In this case, the method is futureValueMaxBalanceMinPurchaseDiscountPercent() This method takes four arguments, corresponding to the four columns of the table. For each subsequent row of the table, SetUpFixture calls that method with the values from the row. As usual, a TypeAdapter is used to convert the cell contents into suitable values for the method. In general:
|