Section 15.4. Business Transactions


15.4. Business Transactions

It was time for Sarah, Emily, and Don to deal with the money, but they weren't sure of all the details. So Mitra, a business analyst, was asked to join the group to help with that and to gain experience with Fit tests.

As Mitra explained: "Customers may start saying what they want to rent, which is entered by the staff member serving them. But when they find that some item is not available, they may cancel everything. We have to ensure that they get the rental items if they want them, so we handle this with a business transaction." "And they can cancel part of it at any time," Don added. "So we need some way of handling that in our tests."

"For a transaction to be completed," Mitra continued, "customers have to have paid or had the amount added to their charge accounts. To cancel after they've paid, they have to first have that payment refunded, or it will be automatically removed as a charge on their accounts."

"So we need to be explicit about the transaction as a business object in our test," said Sarah, "so how about this for the action part of the test?" She sketched out the tables in Figure 15.8: "I've put all the actions to do with the transaction into a single table, as they operate within the context of that transaction."

Figure 15.8. Test Rental Within a Transaction

begin transaction for client

Joanna

rent

100

 

cup

for

2

weeks

check

total is $

210.00

pay with cash $

210.00

check

total is $

0.00

complete transaction


Questions & Answers

Q1:

What do you mean by "business object"?

A1:

In the business domain, that's something that is relevant to our system and that we want to be clear about. Obvious business objects are things like rental items, apartments, vehicles, and accounts. Less obvious are things like time periods and transactions. In RentEz, it doesn't seem as though transactions are to do with the large-scale business, but they certainly underlie much of the business workflow.

We introduced testing of such business objects in Section 10.3 on p. 75.

"There's no need to check the total before and after paying," Mitra recommended. "If the payment isn't for the full amount of the rental cost, the transaction cannot be completed. And the transaction mentions the customer, so there's no need to do that separately in the SetUp."

"We'll need to write some tests for the transaction failing to complete," added Don. "Let's leave that until later." (We cover that in the next section.)

Sarah changed the SetUp to include information about staff, as shown in Figure 15.9.

Figure 15.9. Revised SetUp


She then removed the amount checks from Figure 15.8, resulting in the test shown in Figure 15.10, which assumes the SetUp in Figure 15.9, as usual. The last table in Figure 15.10 was also changed by Don to include staff member Bill in the transaction.

Figure 15.10. Revised Test Rental Within a Transaction




    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