Discount Calculation Test Case

How to Write Discount Calculation Test Cases

A user submitted the following Discount Calculation Test Case and asked for guidance on testing the requirements.

Business Requirements for Promo Code

You need to write as many test cases as possible for a simple software program which
computes the eligible discount for a customer. Try to describe all possible scenarios in a
tabular format. Do not worry about ‘login’ kind of test cases, and just focus on how you will
validate discount calculation. These are the rules.


If the customer is new, and they are willing to sign up for a new loyalty card, they get a 15%
discount on all their purchases on the day. Second if they are an existing customer and hold
a loyalty card, they get a 10% discount. Third, if they have a discount coupon code, they will get
20% off which cannot be used with the new customer discount but can be used with loyalty
card discount. Discount amounts are added, if applicable.

Determining Coupon Code Test Case Variables

Re-read the business requirements and see which actions can lead to different price outcomes. The best way to determine this is to answer What can be changed to arrive at a different outcome?

The primary variables that stick out should be:

  • Customer Status: Is the customer new or existing?
  • Loyalty Card Status: Does the customer have a loyalty card?
  • Discount Coupon Status: Does the customer have a discount coupon or promo code?

Writing the Discount Calculation Gherkin/BDD Test Case

Once the variables are determined, we can begin stubbing out a Gherkin Test Case to test the requirements and ensure our software functions properly. We suggest using a modern Test Case Management Tool, like AccelaTest, to track, document, and execute your test cases. If you want to be added to these test cases in AccelaTest, contact us at bugbanishers@accelatest.com.

Here are the Gherkin Steps we could create:

GIVEN customer is @customerStatus

AND customer @doesCustomerHaveLoyaltyCard have a loyalty card

AND customer @doesCustomerHaveAnotherDiscount have another discount

AND the total cost of goods before discounts is $100

WHEN checking out

THEN the @loyaltyCardDiscountApplication apply

AND the @couponDiscountApplication apply

AND the total amount due is @totalAmount

@customerStatus @doesCustomerHaveLoyaltyCard @doesCustomerHaveAnotherDiscount @loyaltyCardDiscountApplication @couponDiscountApplication @totalAmount
New does not does not does not does not 100
New Does does not does Does not 85
New Does Does Does not Does 80
New Does not Does Does not Does 80
Existing Does not Does not Does not Does not 100
Existing Does Does not Does Does not 90
Existing Does Does Does Does 70
Existing Does not Does Does not Does 80

Validating Coupon Code Business Requirements

As seen above, the requirements stipulate a multi-discount scenario applies to existing customers and result in a deeper discount than a new customer with a coupon code. Seeing this would make me question the requirement with the Business Analyst and ensure its validity.

The customer would be better off signing up for the loyalty card, buying a pack of gum, and then stacking their coupon codes.

Discount Calculation Test Case Conclusion

Creating discount calculation tests is not difficult and can be easily achieved. All you need to do is answer the question, What can be changed to arrive at a different outcome?

Once you have answered this question, you should present your tests to the developer and business analyst in a Three Amigos Session. This will allow the developer to understand what will be tested and the Business Analyst to correct any misunderstandings before code is created.

ACCELATEST UNIVERSITY
Hello there
Do you want to learn the Software Testing techniques, tips, and tricks that have led to a stable, high-paying job and prevented embarrassing multimillion-dollar bugs?