An Introductory Acceptance Test

[article]

satisfied.” Tom continued, “Now it was a matter of how we were going to use these tests to test the system.”

Implementing the Acceptance Tests

Debbie states, “Tom and I needed to apply these tests to my implementation. There are at least four ways we could do this. First, Tom could create a test script that operates manually at the user interface level. Second, I could create a test user interface that allows me or Tom to check the appropriate discount percentages. Third, I could perform the tests using a unit testing framework. A standard unit testing framework is generically called XUnit. Fourth, Tom and I could implement the tests with an acceptance test framework. Let me show you some examples of how we could have dealt with each of these ways”.

Test script

Debbie continues, “In this case, the program had a user interface that allows a customer to enter an order. The user interface flow was much like Amazon or other order sites. The user entered an order and a summary screen appeared, such as this one:”

Order Summary

 

 

 

Count

Item

Item Price

Total

10

Little Widget

$.10

$1.00

1

Big Widget

$9.00

$9.00

 

 

Item Total

$10.00

 

 

Discount

$0.00

 

 

 

 

 

Taxes

 

Shipping

 

Order Total

$.55

$2.00

$12.55

 

 

 

 

 

 

“Now what Tom would have to do is create a script that either he or me would follow in order to test each of the six examples. He might start by computing what the actual discount amount should be for each case. Unless the order summary screen shows this percentage, this is the only output he can check to make sure the calculation is correct. So here’s the addition to the table:”

Discount

 

 

 

Item Total

Customer Rating

Discount percentage?

Discount Amount?

10.00

Good

0.0

0.00

10.01

Good

1.0

0.10

50.01

Good

1.0

0.50

.01

Excellent

1.0

0.00

50.00

Excellent

1.0

0.50

50.01

Excellent

5.0

2.50

“The script would go something like this:

  1. Logon as a Customer who has the Rating listed in the table.
  2. Start an order and put items in it until the total is the specified amount in the Item Total column on the test.
  3. Check that the discount on the Order Summary screen matches Discount Amount in the table.”

“Then the test would be repeated five more times for all six cases. Either he or I would do this once I’ve completed implementing the discount feature.”

Tom interrupts, “Of course, I’d want Debbie to do this before she turned the program over to me. Better for her to get carpal tunnel syndrome, then for me.”

Debbie glances over at Tom with a wry smile on her face. She continues, “Actually, neither of us wants to get carpal tunnel syndrome. It’s bad for our tennis game.”

“This test that checks for the correct discount amount needs to be run not just once, but for all the possible combinations. You can imagine what might have happened if there were ten discount percentages for each of ten different customer types. I’d definitely have let Tom do the tests so his hand would not be in shape for our next tennis match. So let’s look at the next possible way to run these tests.”

Testing User Interface

“To simplify executing the tests, I could set up a user interface that connected to the discount calculation module in my code. This interface would only be used during testing. But having it would cut down on the work involved in showing that

Tags: 

About the author

Ken Pugh's picture Ken Pugh

A fellow consultant with Net Objectives, Ken Pugh has more than two-fifths of a century of experience in software development—from gathering requirements for stock market analysis to testing real-time radar systems. Ken consults, trains, testifies, and mentors from London to Sydney on lean/agile processes and technology topics ranging from object-oriented design and test-driven development to Linux/Unix. He has written several programming books, including the Jolt Award winner Prefactoring and Interface Oriented Design. He is currently writing Lean-Agile Acceptance Test-Driven Development. When not computing, Ken enjoys snowboarding, windsurfing, biking, and hiking the Appalachian Trail. Ken can be reached at ken.pugh@netobjectives.com.

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!

Upcoming Events

Sep 22
Sep 24
Oct 12
Nov 09