Section 38.1. Using SetUpFixture


38.1. Using SetUpFixture

A SetUpFixture table may be used for setting up the data at the start of a test, as we saw in Section 10.4 on p. 76. The setup table from that example is shown again in Figure 38.1. The fixture for that example was covered in Section 28.7 on p. 239, and is shown again in Listing 38.1.

Figure 38.1. SetUp Table

set ups

future value

max balance

min purchase

discount %

low

0.00

0.00

0

medium

0.00

500.00

5

medium

500.00

500.00

3

high

500.00

2000.00

10

high

1000.00

500.00

5


The method futureValueMaxBalanceMinPurchaseDiscountPercent() in class SetUpDiscounts in Listing 38.1 is called for each data row in the table. The name of the method is derived from concatenating the labels in the header row of the table.

Listing 38.1. SetUpDiscounts.java
 public class SetUpDiscounts extends SetUpFixture {    private DiscountApplication app;    public SetUpDiscounts(DiscountApplication app) {       this.app = app;    }    public void futureValueMaxBalanceMinPurchaseDiscountPercent(          String futureValue, double maxBalance, double minPurchase,          double discountPercent) {       app.addDiscountGroup(futureValue,maxBalance,                minPurchase,discountPercent);    } } 



    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