Section 3.4. Selecting a Phone Number


3.4. Selecting a Phone Number

Our third example illustrates the use of simple lists in tests. The business rule for this example is very simple.

The first phone number in the list of supplied phone numbers will normally be used for communicating with the client.

A single test is shown in Figure 3.5. The phones column contains a comma-separated list of phone numbers. The calculated column first() selects the first one in the list.

Figure 3.5. Fit Table for Testing First Phone

CalculateFirstPhoneNumber

phones

first()

(209)373 7453, (209)373 7454

(209)373 7453


When the elements of a list are more complex, such as containing details of each order item within an order, this approach doesn't work. A RowFixture table can be used instead, as discussed in Chapter 5.

Questions & Answers

Q1:

What if an element in the list contains a comma (,)?

A1:

In that case, a RowFixture tables could be used, as covered in Chapter 5. If you wanted to use such lists in a ColumnFixture, a programmer would need to write some fixture code to handle that specially, as we discuss in Chapter 25.

Q2:

What happens if the phone list is empty?

A2:

The business rule doesn't cover that situation, but it does need to be defined. We take up this issue in Chapter 9, when we talk about handling various expected errors.

Programmers

The fixture code for the tests here is given in Section 21.3 on p. 184.




    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