Home > Articles

  • Print
  • + Share This
This chapter is from the book

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.

Table 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.

Table 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

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

    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.

  • + Share This
  • 🔖 Save To Your Account