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
| ID | Category | Test case | Expected result |
|---|---|---|---|
| V01 | Functional | Select coffee, pay exactly ₹20 in coins | Cup drops, coffee fills to the line, screen says the drink is ready |
| V02 | Functional | Order each of the six drinks once | Each is the right drink in the right volume |
| V03 | Functional | Order coffee at each sugar level | Sugar dose differs as specified; "no sugar" has none |
| V04 | Functional | Order small and large | Volumes match the spec for each size |
| V05 | Functional | Change the selection before paying | The latest selection is made and its price charged |
| V06 | Functional | Select a drink, then press Cancel before paying | Machine returns to the start screen |
Payment
| ID | Category | Test case | Expected result |
|---|---|---|---|
| V07 | Functional | Pay ₹50 for a ₹20 coffee | ₹30 change returned correctly; drink dispensed |
| V08 | Negative | Empty the change tubes, then select a drink | Screen shows "exact amount only" before money is accepted |
| V09 | Negative | Insert a bad test coin and a torn test note | Both rejected and returned |
| V10 | Negative | Insert ₹10, then press Cancel | ₹10 returned in full |
| V11 | Negative | Insert ₹10 for a ₹20 drink and walk away | After the timeout the money is returned or held as credit, as specified |
| V12 | Functional | Pay by UPI QR in test mode | Drink dispensed once after the machine receives confirmation |
| V13 | Negative | UPI payment succeeds but the machine fails to dispense | Refund raised automatically with a reference shown on screen; operator log records it |
| V14 | Negative | UPI payment pending or failed | No drink; clear message; no second charge when the user tries again |
| V15 | Negative | Scan and pay the same QR twice quickly | One drink, one charge; the second payment is refused or refunded |
Stock and error states
| ID | Category | Test case | Expected result |
|---|---|---|---|
| V16 | Negative | Run out of cups | All drinks blocked before payment; screen says out of cups |
| V17 | Negative | Run out of milk powder | Milk drinks disabled; black coffee and hot water still available |
| V18 | Negative | Turn off the water supply | Machine stops taking payment and shows a message |
| V19 | Functional | Do not take the finished cup, then select the next drink | Machine waits, or proceeds safely, as specified; no cup dropped onto a full cup |
| V20 | Negative | Cut power during dispensing, then restore it | No repeat dispense; money or UPI payment for the lost drink is refunded or credited |
| V21 | Negative | Let the drip tray fill | Warning shown; machine stops before it overflows |
Hygiene and safety
| ID | Category | Test case | Expected result |
|---|---|---|---|
| V22 | Functional | Measure drink temperature and watch the nozzle | Temperature within spec; no splash outside the cup |
| V23 | Functional | Wait for the scheduled cleaning cycle | Cycle runs; machine refuses orders during it and says so |
| V24 | Security | Try to open the ingredient door and enter the service menu without a key or PIN | Both stay locked |
| V25 | Security | Check what the operator log stores for UPI payments | Only the references needed; no customer personal data beyond what the provider sends |
Accessibility and UI
| ID | Category | Test case | Expected result |
|---|---|---|---|
| V26 | UI | Look at the menu before paying | Every price is visible before payment |
| V27 | UI | Order a drink and watch the screen | Progress shown while preparing; clear "take your drink" at the end |
| V28 | UI | Check button and cup-slot height | Usable by a wheelchair user, if required by the site's accessibility policy |
Performance and reporting
| ID | Category | Test case | Expected result |
|---|---|---|---|
| V29 | Performance | Time payment-to-drink for coffee | Within the spec |
| V30 | Performance | Make 20 coffees back to back | Temperature and volume stay within spec for every cup |
| V31 | Functional | Compare the service menu's sales and stock counters with the test orders | Counters 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.
