Skip to content
QA Knowledge Hub

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

IDCategoryTest caseExpected result
C01FunctionalAdd QA-NOTE once to an empty cartOne line shows quantity 1 and merchandise total ₹250
C02FunctionalAdd two QA-NOTE and three QA-PENTwo lines total ₹620 before any coupon
C03FunctionalAdd QA-NOTE again to its existing lineQuantity increases by one with no duplicate SKU line
C04FunctionalAdd two different variants of one productVariant identities remain separate in cart and checkout data
C05FunctionalChange QA-PEN quantity from 3 to 2Its line becomes ₹80 and the two-notebook cart becomes ₹580
C06FunctionalRemove QA-NOTE from the ₹620 fixtureOnly three QA-PEN remain and merchandise total is ₹120
C07FunctionalRemove the final itemEmpty state appears and checkout is unavailable
C08BoundarySet an in-stock line to quantity 1 and then 10Both are accepted and totals match unit price times quantity
C09BoundaryEnter quantity 0 or 11Update is rejected with the 1–10 limit; last valid quantity remains
C10NegativeSubmit a negative or fractional quantity directlyServer rejects it without changing cart totals

Pricing and availability

IDCategoryTest caseExpected result
C11FunctionalApply QA100 to two QA-NOTEDiscount is ₹100 and discounted merchandise total is ₹400
C12BoundaryApply QA100 to a fixture worth ₹499Coupon is rejected and total remains ₹499
C13NegativeApply QA100 twice to the same eligible cartOnly one ₹100 discount is applied
C14FunctionalRemove an item so eligible merchandise falls below ₹500Coupon is removed with an explanation and undiscounted total is restored
C15NegativeUse an expired coupon fixtureNo discount applies and an expiry message appears
C16FunctionalChange catalogue price while a cart is open, then refresh itCurrent server price is shown with a price-change notice before checkout
C17NegativeMake a cart item out of stock before checkoutItem is flagged and cannot be purchased without resolving availability
C18BoundaryRequest quantity 3 when only 2 remainCart reports the stock limit and does not approve 3 for checkout

Persistence and integrity

IDCategoryTest caseExpected result
C19FunctionalRefresh after a confirmed quantity changeServer-confirmed quantity and total are restored
C20FunctionalMerge guest quantity 2 with signed-in quantity 3 of QA-NOTEOne quantity-5 line remains
C21BoundaryMerge guest quantity 6 with signed-in quantity 6Quantity is capped at 10 and the unmerged excess is explained
C22SecuritySign out account A and sign in account B on a shared browserB never receives A private cart contents
C23SecurityChange cart identifier to another account cartServer refuses read and update access
C24SecuritySend ₹1 as client unit price for QA-NOTEServer uses the ₹250 catalogue fixture price
C25FunctionalEdit the same line in two tabs using stale cart versionsConflict is surfaced or reconciled; final server quantity and both refreshed views agree
C26NegativeLose a quantity-update response after server acceptanceRecovery reloads confirmed quantity without applying the change twice

Presentation and scale

IDCategoryTest caseExpected result
C27UIReview a long product name and variant on a narrow screenQuantity, variant, price and remove action remain identifiable and operable
C28UIChange quantity using keyboard and screen readerFocus remains usable and the updated total is announced or readily discoverable
C29PerformanceLoad and update a cart at the agreed maximum line countOperations meet the agreed budget and totals include every line
C30CompatibilityRepeat add, refresh and guest merge on supported browsersPersisted 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.