Test cases for a shopping cart
Updated 2026-11-13 · 6 min read
Thirty cases spanning cart arithmetic, guest-to-account merges and stale stock. Fake SKU prices and a defined coupon rule provide concrete expected totals.
How to answer in an interview
Ask when stock is reserved, how guest carts survive a return visit and how quantity limits interact with promotions. Start with a two-item total, then discuss concurrent edits and stale prices. A cart that looks correct can still submit a price or quantity the server should refuse.
Scope and test data
Use fake SKUs QA-NOTE at ₹250 and QA-PEN at ₹40. For this example, quantities are integers from 1 to 10, stock is not reserved until checkout, identical SKUs merge, and distinct variants remain separate. A fixture coupon QA100 subtracts ₹100 once from merchandise totals of at least ₹500; shipping and tax are calculated at checkout. A guest-to-account merge adds quantities up to the limit and reports excess. OWASP business-logic guidance supports deriving prices and enforcing ownership on the server; the promotion and merge rules here are invented test requirements.
The 30 cases below are a test design, not an execution report. Replace the example rules with approved requirements before recording pass or fail. Performance budgets and supported device versions must be agreed before execution.
Items and quantities
| ID | Category | Test case | Expected result |
|---|---|---|---|
| C01 | Functional | Add QA-NOTE once to an empty cart | One line shows quantity 1 and merchandise total ₹250 |
| C02 | Functional | Add two QA-NOTE and three QA-PEN | Two lines total ₹620 before any coupon |
| C03 | Functional | Add QA-NOTE again to its existing line | Quantity increases by one with no duplicate SKU line |
| C04 | Functional | Add two different variants of one product | Variant identities remain separate in cart and checkout data |
| C05 | Functional | Change QA-PEN quantity from 3 to 2 | Its line becomes ₹80 and the two-notebook cart becomes ₹580 |
| C06 | Functional | Remove QA-NOTE from the ₹620 fixture | Only three QA-PEN remain and merchandise total is ₹120 |
| C07 | Functional | Remove the final item | Empty state appears and checkout is unavailable |
| C08 | Boundary | Set an in-stock line to quantity 1 and then 10 | Both are accepted and totals match unit price times quantity |
| C09 | Boundary | Enter quantity 0 or 11 | Update is rejected with the 1–10 limit; last valid quantity remains |
| C10 | Negative | Submit a negative or fractional quantity directly | Server rejects it without changing cart totals |
Pricing and availability
| ID | Category | Test case | Expected result |
|---|---|---|---|
| C11 | Functional | Apply QA100 to two QA-NOTE | Discount is ₹100 and discounted merchandise total is ₹400 |
| C12 | Boundary | Apply QA100 to a fixture worth ₹499 | Coupon is rejected and total remains ₹499 |
| C13 | Negative | Apply QA100 twice to the same eligible cart | Only one ₹100 discount is applied |
| C14 | Functional | Remove an item so eligible merchandise falls below ₹500 | Coupon is removed with an explanation and undiscounted total is restored |
| C15 | Negative | Use an expired coupon fixture | No discount applies and an expiry message appears |
| C16 | Functional | Change catalogue price while a cart is open, then refresh it | Current server price is shown with a price-change notice before checkout |
| C17 | Negative | Make a cart item out of stock before checkout | Item is flagged and cannot be purchased without resolving availability |
| C18 | Boundary | Request quantity 3 when only 2 remain | Cart reports the stock limit and does not approve 3 for checkout |
Persistence and integrity
| ID | Category | Test case | Expected result |
|---|---|---|---|
| C19 | Functional | Refresh after a confirmed quantity change | Server-confirmed quantity and total are restored |
| C20 | Functional | Merge guest quantity 2 with signed-in quantity 3 of QA-NOTE | One quantity-5 line remains |
| C21 | Boundary | Merge guest quantity 6 with signed-in quantity 6 | Quantity is capped at 10 and the unmerged excess is explained |
| C22 | Security | Sign out account A and sign in account B on a shared browser | B never receives A private cart contents |
| C23 | Security | Change cart identifier to another account cart | Server refuses read and update access |
| C24 | Security | Send ₹1 as client unit price for QA-NOTE | Server uses the ₹250 catalogue fixture price |
| C25 | Functional | Edit the same line in two tabs using stale cart versions | Conflict is surfaced or reconciled; final server quantity and both refreshed views agree |
| C26 | Negative | Lose a quantity-update response after server acceptance | Recovery reloads confirmed quantity without applying the change twice |
Presentation and scale
| ID | Category | Test case | Expected result |
|---|---|---|---|
| C27 | UI | Review a long product name and variant on a narrow screen | Quantity, variant, price and remove action remain identifiable and operable |
| C28 | UI | Change quantity using keyboard and screen reader | Focus remains usable and the updated total is announced or readily discoverable |
| C29 | Performance | Load and update a cart at the agreed maximum line count | Operations meet the agreed budget and totals include every line |
| C30 | Compatibility | Repeat add, refresh and guest merge on supported browsers | Persisted contents and calculated totals agree across the supported matrix |
Evidence and prioritisation
Use C02 as the arithmetic oracle and C24 as the trust-boundary check. Capture the catalogue fixture, cart version and response alongside screenshots; a screenshot alone cannot establish that the submitted price was safe. Ask the interviewer whether adding an item reserves stock: this suite deliberately does not assume it does. Continue with checkout cases, where availability is checked again.
Downloads
Quick answers
Is adding to cart a stock reservation?
Only if the product says so. This suite checks stock again at checkout.
How should two carts merge?
Choose a documented rule for duplicates, limits and promotions. This suite adds identical SKU quantities, caps at ten and reports excess.
Sources
Want a project you can show in interviews?
The portfolio project kit walks you through testing a deliberately buggy app with Selenium or Playwright and API tests, then explaining it. The app itself is free.
