Skip to content
QA Knowledge Hub

Test cases for a coffee or vending machine

Updated 2026-11-13 · 6 min read

A vending machine is a small state machine with money in it. These 31 cases cover selection, cash and UPI payment, change and refunds, stock and error states, hygiene, accessibility and speed.

Assumes an office coffee machine with six drinks (coffee, black coffee, tea, masala tea, hot milk, hot water), three sugar levels, two cup sizes, payment by coins, notes and a UPI QR code shown on screen, and a service menu for the operator.

How to answer in an interview

Ask first: which drinks and options, how does it take payment (coins, notes, UPI, office ID card, or free), does it give change, does it drop cups or need your own, how is it cleaned, and does it report stock to the operator? Then walk through: selection and dispensing, payment, stock and error states, hygiene and safety, accessibility, and performance. Point out that money flows need the most failure cases.

Scope and test data

Example prices: coffee ₹20 and hot water ₹5 (replace with the real price list). Use the supplier's test coins and notes, including known-bad samples for rejection tests. UPI tests use a sandbox or a test merchant account and the machine's test mode; never a personal account. Volume, temperature and preparation time limits must come from the machine's specification. These are designed cases, not an execution report.

Selection and dispensing

IDCategoryTest caseExpected result
V01FunctionalSelect coffee, pay exactly ₹20 in coinsCup drops, coffee fills to the line, screen says the drink is ready
V02FunctionalOrder each of the six drinks onceEach is the right drink in the right volume
V03FunctionalOrder coffee at each sugar levelSugar dose differs as specified; "no sugar" has none
V04FunctionalOrder small and largeVolumes match the spec for each size
V05FunctionalChange the selection before payingThe latest selection is made and its price charged
V06FunctionalSelect a drink, then press Cancel before payingMachine returns to the start screen

Payment

IDCategoryTest caseExpected result
V07FunctionalPay ₹50 for a ₹20 coffee₹30 change returned correctly; drink dispensed
V08NegativeEmpty the change tubes, then select a drinkScreen shows "exact amount only" before money is accepted
V09NegativeInsert a bad test coin and a torn test noteBoth rejected and returned
V10NegativeInsert ₹10, then press Cancel₹10 returned in full
V11NegativeInsert ₹10 for a ₹20 drink and walk awayAfter the timeout the money is returned or held as credit, as specified
V12FunctionalPay by UPI QR in test modeDrink dispensed once after the machine receives confirmation
V13NegativeUPI payment succeeds but the machine fails to dispenseRefund raised automatically with a reference shown on screen; operator log records it
V14NegativeUPI payment pending or failedNo drink; clear message; no second charge when the user tries again
V15NegativeScan and pay the same QR twice quicklyOne drink, one charge; the second payment is refused or refunded

Stock and error states

IDCategoryTest caseExpected result
V16NegativeRun out of cupsAll drinks blocked before payment; screen says out of cups
V17NegativeRun out of milk powderMilk drinks disabled; black coffee and hot water still available
V18NegativeTurn off the water supplyMachine stops taking payment and shows a message
V19FunctionalDo not take the finished cup, then select the next drinkMachine waits, or proceeds safely, as specified; no cup dropped onto a full cup
V20NegativeCut power during dispensing, then restore itNo repeat dispense; money or UPI payment for the lost drink is refunded or credited
V21NegativeLet the drip tray fillWarning shown; machine stops before it overflows

Hygiene and safety

IDCategoryTest caseExpected result
V22FunctionalMeasure drink temperature and watch the nozzleTemperature within spec; no splash outside the cup
V23FunctionalWait for the scheduled cleaning cycleCycle runs; machine refuses orders during it and says so
V24SecurityTry to open the ingredient door and enter the service menu without a key or PINBoth stay locked
V25SecurityCheck what the operator log stores for UPI paymentsOnly the references needed; no customer personal data beyond what the provider sends

Accessibility and UI

IDCategoryTest caseExpected result
V26UILook at the menu before payingEvery price is visible before payment
V27UIOrder a drink and watch the screenProgress shown while preparing; clear "take your drink" at the end
V28UICheck button and cup-slot heightUsable by a wheelchair user, if required by the site's accessibility policy

Performance and reporting

IDCategoryTest caseExpected result
V29PerformanceTime payment-to-drink for coffeeWithin the spec
V30PerformanceMake 20 coffees back to backTemperature and volume stay within spec for every cup
V31FunctionalCompare the service menu's sales and stock counters with the test ordersCounters match the orders made, including refunds

What to prioritise

Money first: V07, V08, V13, V15 and V20. Then the drink itself (V01 to V04). In an interview, a common mistake is to treat UPI on a vending machine like an app: the machine has no "back" button, so the only acceptable outcomes are a drink or a refund the customer can see.

Downloads

Quick answers

What is the most important vending machine test case?

The customer pays and gets nothing (V13, V20). Whether payment is by coins or UPI, the machine must either dispense or refund, and the operator must be able to see what happened.

How is this different from testing an ATM?

The structure is the same (select, pay, dispense, handle failures) but the risks differ: a vending machine adds product quality, hygiene and stock, while an ATM adds PIN security and bank reconciliation.

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.