Section 15.5. Sad Paths


15.5. Sad Paths

Don was eager to focus on "when the transaction can't complete." In testing, this is often called a sad path because it concerns what happens when things don't work out well. After discussion and a few trials, the group came up with the first sad-path test, as shown in Figure 15.11.

Figure 15.11. Testing a Transaction That Can't Complete

begin transaction for client

Joanna

staff

Bill

rent

100

 

cup

for

2

weeks

reject

complete transaction

pay with cash $

210.00

complete transaction


No payment has been made in the third row of Figure 15.11. So the complete transaction in the third table must be rejected by the system under test. Once the payment has been made in the fourth row, the transaction can be completed.

The group wrote 20 more sad-path tests for complete and cancel transactions, including the one shown in Figure 15.12. A transaction can't be canceled until any paid money is refunded.

Figure 15.12. Testing a Transaction That Can't Be Canceled

begin transaction for client

Joanna

staff

Bill

rent

100

 

cup

for

2

weeks

pay with cash$

410.00

reject

cancel transaction

refund cash$

410.00

cancel transaction


Questions & Answers

Q1:

But doesn't the test in Figure 15.11 consist of two tests?

A1:

Yes, you're right, with the first test simply checking that the complete transaction was rejected. We also need to check that a previously rejected completion of a transaction can be completed later.

However, the test is so short that splitting it into two doesn't seem worthwhile, especially as there are no other cases yet. There's usually a judgment call and often a tradeoff in such decisions, and people differ in their approach to this issue.



    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