Fit for Developing Software: Framework for Integrated Tests
28.8. CalculateFixture Tables
The third table in Figure 28.6 makes use of a CalculateFixture table, CalculateDiscounts2, which is returned by the method calculateWithFutureValue() in Listing 28.8. The fixture class CalculateDiscounts2 is shown in Listing 28.10. In a similar way to SetUpFixture, the labels in the second row of the table are combined to form a method name. Here, the method name discountOwingPurchase() is made up from the expected column label, followed by the given column labels. For each of the following rows of the table, the method is called with two arguments from the two given columns. The result of the method call is checked against the calculated column for that row, and that cell is colored appropriately. Listing 28.10. CalculateDiscounts2.java
public class CalculateDiscounts2 extends CalculateFixture { private DiscountApplication app; private String futureValue; public CalculateDiscounts2(DiscountApplication app, String futureValue) { this.app = app; this.futureValue = futureValue; } public double discountOwingPurchase(double owing, double purchase) { return app.discount(futureValue,owing,purchase); } }
In general:
|