An Introductory Acceptance Test

[article]
Summary:

"If you don't know where you are going, you will wind up somewhere else." Yogi Berra

This article is an excerpt from Ken Pugh’s upcoming book – “Lean-Agile Acceptance Test Driven Development” to be published by Addison-Wesley. Debbie, the developer, and Tom, the tester, are introducing acceptance test-driven development to Cathy, the customer.

The Triad – Tom, Debbie, and Cathy – are in their second meeting together. Debbie describes an example of an acceptance test and four ways that an acceptance test can be executed.

 

An Example Business Rule

Debbie, Tom, and Cathy continue their discussion of Acceptance Test-Driven Development. Debbie is talking about a previous project where she and Tom created tests in collaboration with the customer.

“The business representative, Betty, presented us with a business rule for giving discounts that she had obtained from one of the stakeholders. The stakeholder wanted to give discounts to the firm’s customers. The discount was to vary based on the type of customer. We had already completed implementing a previous requirement that determined the type of customer. Here’s the rule that Betty gave to us:”

If Customer Type is Good and the Item Total is less than or equal $10.00,

Then do not give a discount,

Otherwise give a 1% discount.

If Customer Type is Excellent,

Then give a discount of 1% for any order.

If the Item Total is greater than $50.00,

Then give a discount of 5%.

“This rule seems pretty clear. It uses consistent terms such as ‘Customer Type’ and ‘Item Total’. We had previously gotten from Betty the definitions of those terms. (Footnote – See Eric Evan’s Domain Driven Design) For example, the ‘Item Total’ did not include any taxes or shipping. But even with that consistency, we had an issue. Tom and I looked at the rule and tried to figure out what the discount percentage should be if a customer who is good had an order total greater than $50.00. So the three of us made up a table of examples”. (Footnote – See Brian Marick’s Example Driven Development at http://www.exampler.com)

Discount

 

 

Item Total

Customer Rating

Discount percentage?

10.00

Good

0.0

10.01

Good

1.0

50.01

Good

1.0 ??

.01

Excellent

1.0

50.00

Excellent

1.0

50.01

Excellent

5.0

Debbie continues, “The first two rows show that the limit between giving a Good customer a discount or a 1.0% discount is $10.00. The ‘less than or equal’ in the business rule is pretty clear. But we wanted a test to ensure that my implementation produced that result. We put a ‘??’ after the ‘1.0’ in the third example, since it was unclear to us whether that was the right value.”

“The fourth example indicates that we understand that the discount for an Excellent customer starts at the smallest possible Item Total. The fifth and sixth entries show that the discount increases after $50.00.”

“Betty took this table back to the stakeholder. He looked it over and said that the interpretation was correct. He did not want to give a 5% discount to Good customers. So we removed the ‘??’ from that result. We now had a set of tests that we could apply to the system.”

Tom interjects, “But these were not all the tests. Being trained as a tester, I like to consider other possibilities. For example, what if the Item Total was less than $0.00? I asked Betty whether this would ever happen. She said it might be possible, since the Item Total could include a rebate coupon that was greater than the total of the items. So I added the following possibilities:”

Discount

 

 

Item Total

Customer Rating

Discount percentage?

-.01

Good

0.0

-.01

Excellent

1.0 ??

Tom explains, “It didn’t seem right to apply a discount percentage that would actually increase the amount that was charged to the customer. Based on this example, Betty went back to the stakeholder and confirmed that the percentage should be 0% if the Item Total is less than 0 for any customer.”

“These examples were the acceptance tests for the system. If Debbie implemented these correctly, Betty would be

Pages

Tags: 

About the author

AgileConnection is one of the growing communities of the TechWell network.

Featuring fresh, insightful stories, TechWell.com is the place to go for what is happening in software development and delivery.  Join the conversation now!