Blog reader Angee Tong asks the following interesting question about equivalence partitioning:
I have a question on the sample test analyst exam question below. I can’t figure out how the answer is derived. Can you walk me through the solution for this exam question?
You are testing a computerized gas pump that allows users to pay using credit cards.
Four types of cards are accepted: Visa, MasterCard, Discover, and American Express. The pump will reject any other type of card. If given an accepted credit card, the pump validates the card. If the card is valid, the pump is turned on and the customer is told to begin pumping gas. The pump remains on until the transaction ends. The transaction ends when one of the following events occurs:
1. Pump handle is returned to the pump.
2. Amount reaches transaction limit for card
3. No gas is pumped within 2 minutes of validation of card
4. Emergency shut-off switch is thrown by the station attendant.
Assume that a test is consists of a triple set of values (card type, card validity, transaction ending). Design the minimum number of tests needed to cover all the equivalence partitions for each card brand, including both valid and invalid cards of each accepted type along with covering each equivalence partition for transaction endings. How many tests do you need?
I came up with 17 tests but it is the wrong answer. My reasoning is I counted the amount reaches card limit or within card limit count as two other equivalence partitions as well. Also I counted the emergency shut-off option as an equivalence partition. Should these three items not be counted as equivalence partitions? Can you explain how the answer 9 is derived?
Can you provide other sample questions similar to this for additional practice so I can make sure I learned to apply the test technique correctly? Thank you.
Test Case Card No Gas Is Pumped Within 2+ Minutes Amount Within Card Limit Gas Is Pumped Within 2 Minutes Pump Handled Returned to Pump Amount Reaches Card Limit Emergency Shut-Off 1 Invalid Card 2 Visa Y Y 3 Master Card Y Y 4 Discover Y Y 5 Amex Y Y 6 Visa Y Y 7 MasterCard Y Y 8 Discover Y Y 9 Amex Y Y 10 Visa Y 11 MasterCard Y 12 Discover Y 13 Amex Y 14 Visa Y 15 MasterCard Y 16 Discover Y 17 Amex Y
Angee, what you’ve done in your solution is a form of combinational testing. In other words, you are testing each combination of credit card with transaction ending. That is not required for equivalence partitioning. In addition, you’re not testing the invalid card numbers for each accepted card type.
The answer is nine tests. Here’s why. There are four equivalence partitions for transaction endings. Those are all valid partitions. There are nine equivalence partitions for cards: four valid card numbers, one for each type; four invalid card numbers, one for each type; and, one invalid card type (e.g., a JCB).
Angee, there are a number of other practice questions for equivalence partitioning provided in the book and e-learning course. Make sure to go back and do the Foundation sample questions on test design techniques (Chapter 4), too.
Tags: equivalence partitioning