Lean-Agile Acceptance Test-Driven Development: An Introductory Acceptance Test
- A Sample Business Rule
- Implementing the Acceptance Tests
- Testing Process
- Summary
- "If you don't know where you're going, you will wind up somewhere else."
- Yogi Berra
An example of an acceptance test is presented, along with four ways that you can execute an acceptance test.
A Sample Business Rule
Here is an example from a previous project where Debbie and Tom created tests in collaboration with the customer. The business representative, Betty, presented the two of them 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 based on what type of customer they were. Debbie had already completed implementing a previous requirement that determined the customer type. Here's the rule that Betty gave them:
- If Customer Type is Good and Item Total is less than or equal to $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 Item Total is greater than $50.00,
- Then give a discount of 5%.
This rule may seem clear. It uses consistent terms, such as Customer Type and Item Total. Debbie and Tom had previously gotten from Betty the definitions of those terms [Evans01]. For example, Item Total did not include taxes or shipping. But even with that consistency, there was an issue. Tom and Debbie 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 Betty, Debbie, and Tom made up a table of examples.1
Discount Calculation |
||
Item Total |
Customer Rating |
Discount Percentage? |
$10.00 |
Good |
0% |
$10.01 |
Good |
1% |
$50.01 |
Good |
1% ?? |
$.01 |
Excellent |
1% |
$50.00 |
Excellent |
1% |
$50.01 |
Excellent |
5% |
The answers in this table of examples are going to be used to test the implementation. The first two rows show that the limit between giving a good customer no discount or a 1% discount is $10.00. The "less than or equal to" in the business rule is pretty clear. The tests just ensure that the implementation produced that result. The ?? was put after the 1 in the third example because it was unclear to the triad whether that was the right value. To what type of customer did the last statement in the rule apply?
The fourth row indicates that the discount for an excellent customer starts at the smallest possible Item Total. The fifth and sixth entries show that the discount increases just after the $50.00 point.2
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 ?? from that result was removed from that cell. There was now a set of tests that could be applied to the system. The correct discount amount test is not just a single case but includes cases for all possible combinations.
Tom suggested other possibilities. For example, what if Item Total was less than $0.00? Tom asked Betty whether this would ever happen. She said it might be possible, because Item Total could include a rebate coupon that was greater than the total of the items. So Tom added the following possibilities.
Discount Calculation |
||
Item Total |
Customer Rating |
Discount Percentage? |
$–.01 |
Good |
0% |
$–.01 |
Excellent |
1% ?? |
Tom explained that it didn't seem right to apply a discount percentage that would actually increase the amount that the customer owed. Based on this example, Betty went back to the stakeholder and confirmed that the percentage should be 0% if Item Total is less than 0 for any customer. So the table became as follows.
Discount Calculation |
||
Item Total |
Customer Rating |
Discount Percentage? |
$–.01 |
Good |
0% |
$–.01 |
Excellent |
0% |
These examples were the acceptance tests for the system. If Debbie implemented these correctly, Betty would be satisfied. Now it was a matter of how Debbie and Tom were going to use these tests to test the system.