How to Write Test Cases for Vending Machines

Test cases for Vending Machine featured image 800x419

How many times have you been sitting around for hours in a hospital waiting room and wished that you could grab a quick snack without missing your appointment?

Or maybe when you wanted to grab a quick snack late afternoon when you’re feeling your sugar levels dip?

Or how about THAT morning when you have a client meeting, missed breakfast and are more worried about your stomach grumbling and embarrassing yourself? 

Thankfully there’s a saving grace.

The Vending Machine!!!

Modern vending machines have been around since the late 1880’s. 

Invented by Percival Everitt in London, they dispensed postcards which later became incredibly popular around the world.

In the US, the first vending machine was used in 1888 and dispensed gum. 

In this article, I will give you a list of test cases for a vending machine as also talk about considerations from a testing perspective.

Before We Begin – Context and Scope

Before we begin, I want to make it clear that the test cases discussed in this article primarily talk about a ‘generic’ vending machine.  

The context of the test cases that are listed below are focussed on a machine that dispenses bars and bags.  The Vendo Machine by Mars is a good example.

If you need to test anything specific, the concept is still the same, just ensure you add appropriate test cases.

Learn how to write test cases that even your Grandparent can write!

Before you start writing your test cases, you should take the following points into consideration.

Consult specific Documentation

In order to test the software correctly, you should ALWAYS consult any documentation for the specific model you have.

For example, requirements, user guides and operating manuals etc.


Consider innovation and ever changing technology.

For example, contactless payment systems are now becoming the norm in Europe and in the Western world.

Digital currencies such as Bitcoin and Ethereum are also starting to take off so should be a consideration when testing vending machines.

In countries like the United Arab Emirates, vending machines are being used to vend gold bars and not just snacks and beverages.

As a result, you might also want to think about the capability of testing additional items your vending machines could dispense.

Funnily enough, I’ve even heard of vending machines that dispense cars.  Yup, you heard that right.

Now just imagine if you made the wrong selection? 

That would be one seriously annoyed customer.

It actually makes me laugh but also blows my mind.

Security Considerations

Whenever you have a product or service that involves money, it’s likely that it will be open to attack.

Therefore, security must be of high importance.

One of the things you need to look at is how someone can potentially get a product for free.

Being a skinny schoolkid and having the thinnest arms, I remember trying to put my hand in the bottom and trying to lift the flap to try and get a can of drink out.

It never worked.

Another trend in the early 1990’s was putting foil around two 5p coins in making the machine think it was a £1 coin.

That never worked either and often it got stuck in the machine.

You ended up losing your money.anyway.

You get my point.

People will always try to outsmart these machines, so you need to try and think with a similar mindset.

Uses for a vending Machine

The possibilities of what a Vending machine can be used for are endless.

I can’t list them all here or we’d be here all day.

However, I do want to add a few different types so that you can get a feel for what’s available, and to let your ‘testing’ brain get to  work.

A coffee machine is one that instantly comes to mind.

I remember on a late evening in November 2019 when I had to visit Great Ormond Street Hospital in London and the canteen was shut.  

I was starving and as I left the canteen, there standing in the corner was this bright shining vending machine where you could purchase ‘proper’ food. 

I found it really intriguing.

I opted for the vegetarian curry.

So I put in the money in, out it came and then all you had to do was to warm it up in the microwave provided.

I’d never seen that before.

The curry tasted absolutely disgusting but thats beside the point.

It was very convenient and very user friendly.

No wonder these things are so popular.


Interesting Engineering wrote an article which is not only interesting (excuse the pun) but funny at the same time.

If you want to have a laugh, then watch the video below which also shows vending machines that you may not have known existed.

You should get some ideas on functionality and usability.

Functional test cases

So now that we’ve got an idea, let’s get down to the actual test case for your vending machine.

The purpose of the functional test cases is to ensure that you can run them during a System Test or System Integration Testing level and prove that each functional requirement has been validated.

You may need to break down each test case further into steps if you want to test to a granular condition level.

End User Selects a Product

We want to ensure that each functional area works individually before it can be tested end to end.

The test cases below consider an end user of the machine who wants to purchase a product.  

TC IDTest Case DescriptionExpected Result
TC-SP-001Verify User can Select product on keypadThe keypad is working

User selection is displayed on the keypad.

The system will prompt the user to make a payment.
TC-SP-002Verify User has inserted cashSystem displays how much money user has entered on the keypad.

The number is accrue as the coins are inserted.
TC-SP-003Verify User has inserted correct money (exact change)The system will display the amount entered is the amount required to dispense the product.
TC-SP-004Verify Not enough money is insertedSystem will display amount entered

When user selects a product greater than the amount inserted, the system will display a message, for example
“Not enough funds”.

User will not be able to select the product.

System will NOT dispense the product selected.
TC-SP-005Verify change has to be given when user inserts more cash than product cost.The system will display the amount entered on screen.

The product will get dispensed first.

The change will also be dispensed.

For example, product cost is £0.70 and the user inserts a £1 coin.

The vending machine will dispense the product followed by £0.30 in change.
TC-SP-006Verify correct product is dispensed when selectedThe product selected will also be dispensed,
Note:  You should visually check this to ensure the product selection corroborates with what has ACTUALLy been stocked. 
TC-SP-007Verify product selected is out of stockThe system will display a message informing the user that the product is out of stock and to make another selection.
For example “Sold Out”.
The system will not have accepted any payment at this point.
TC-SP-008Verify refund/return money feature returns correct money
TC-SP-009Verify not enough change is available when user inserts enough money.The system will display the amount entered in cash on the display.

When the user has selected their product and there is not enough change, the system will;

Return a message informing the user there is not enough change

Not dispense the product.

Or in some cases, the message rtutned may be;

“Use Correct Change”

Note:  In some cases, I have noticed that some machines DO dispense the product but do not give change.

Thieving toeags!
TC-SP-010Verify shaking machine does not dispense any productMessage will be displayed telling the user that shaking machine will not dispense any products or money.

The machine will NOT dispense any product.

Note: In some cases, the machine may automatically switch itself off when it detects someone is tampering with it.
TC-SP-011Verify shaking machine does not dispense any moneyMessage will be displayed telling the user that shaking machine will not dispense any products or money.

The machine will NOT dispense any money.

Note: In some cases, the machine may automatically switch itself off when it detects someone is tampering with it.
TC-SP-012Verify contactless payment is approvedProduct has been selected

System is asking for payment

When user taps Card, the payment is processed and ‘Approved’.

Product is dispensed  and you can happily enjoy your day.
TC-SP-013Verify contactless payment is rejectedProduct has been selected

System is asking for payment

When user taps Card, the payment is processed and ‘Rejected’.

Product is NOT dispensed.

You’re left annoyed, hungry and slightly embarrassed!
TC-SP-014Wrong product was selected by mis-typing on keypad.This is your fault and you should be a bit more careful next time.

Enjoy your product!


Don’t forget that a Vending machine has a whole back-end system.  In this section we’ll go through the more technical and admin features you need to look at testing.

Non Operational Mode

TC IDTest Case DescriptionExpected Result
TC-BE-001Verify vending machine can be put in service modeThe display will inform the user that the machine is currently ‘out of service’.

No products can be purchased.
TC-BE-002Verify machine can be put in operational mode.Prerequisite: The machine must be in a non-operational mode to confirm this works.

The system does not display the machine as ‘out of service’.

User’s are able to purchase products.

Post Requisite: Run a ‘stand up’ test to ensure product is dispensing as expected.

Set Pricing

When setting pricing, ensure the vending machine is in a non-operational mode.

TC IDTest Case DescriptionExpected Result
TC-SP-001Set price for a specific productThe screen will display the current price and allow a change to a new price.

The user should be able to select the row and price.

Note:  Please consult your requirements documentation on how to doi this.

Post Req: Run a stand up to ensure the product dispenses at the correct price.
TC-SP-002Set price by rowThe entire row should have the same price.

Note: Please refer your requirements on how to do this.

Postrequisite: Run a stand up test to ensure that each item in the same row dispenses at the same cost.
TC-SP-003Set the same price for all productsAll products will be the same price.

Note: Please refer your requirements on how to achieve this.

Postrequisite: Run a stand up test to ensure that every item in the vending machine dispenses at the same cost.

Temperature Control

TC IDTest Case DescriptionExpected Result
TC-TC-001Verify the vending machine is operating at the correct temperatureThe system will display the expected temperature once the Admin/Engineer has logged into the systrem

Note:  Please check the requirements for what the temperature will be.  This may vary depending on the type of product being dispensed.
TC-TC-002Verify the vending machine is operating at the incorrect temperatureThe system will display that the temperature is incorrect.

Note:  Please consult your requirements on how this will be achieved.  Ultimately, the system must be able to capture that the temperature is incorrect and be able to let the Admin/Engineer know so it can be resolved.

To get some ideas watch this

Or watch this to get an idea of the User Interface

Money Stock and Sales Reporting

Your test plan should also include test where the system verifies the money in the vending machine.

TC IDTest Case DescriptionExpected Result
TC-MS-001Verify Sales Data
Note: To test, purchase a set number of items.
Make a note of exactly all quantities of products available in the machine, all products purchased, their cost and total sales value.
The data the vending machine returns will corroborate with the number of items and sales made.

Run a visual eye check to ensure it all reconciles.

Replenishing / Stocking up

TC IDTest Case DescriptionExpected Result
TC-RS-001Verify alert when module is removed correctly
TC-RS-002Verify bar module(s) only accept bars
TC-RS-003Verify Maximum stock level has been reached
TC-RS-004Verify module is inserted correctly
TC-RS-005Verify alert when module is not properly closed
TC-RS-006Verify no more than one module is removed 
Assumption is that only 1 module can be removed at a time.

Detect fake coins

Having fake money in vending machines it a loss for the business owner and encourages people to continue to commit fraud.  

As a result, its important for machines to be able to reject fake money.

TC IDTest Case DescriptionExpected Result
TC-DC-001Enter an ineligible coin

Disclaimer:  Please DO NOT use counterfeit money.

One of the best ways to test the vending machine is to check currencies of other countries that
may be similar in size and weight.

Only do this if you have permission and NOT on live machines.

Payment considerations

When it comes to making payments, you might want to also consider the following options.

– Coins

– Contactless 

– Card

– Apple Pay

– Crypto currency payment

Maintenance and Erros

Every now and again your system may have some technical issues.  

The model that you’ll be testing may have a number of error codes.

You should test each error code by trying to create the correct test conditions to generate the error.

TC IDTest Case DescriptionExpected Result
TC-CODE-[CODE ID]Verify Error Code

Note:  This test should be replicated many times until all error codes have been covered.
The error code is displayed on the screen.

Notes / Observations

Check to make sure which products your vending machine can support. For example, can it only support, bars, bags and drinks?

Most vending machines will allow you to;

  • Select a product and then enter payment
  • Or enter payment (mostly cash) and then select product.

Just be mindful that you may have to tweak your test cases accordingly, especially when it comes to refunds.

Test Case Maintenance and Regression Test Pack Creation

We can’t talk about testing if we don’t mention a regression test pack.

Your Ultimate Guide to Regression Testing

As I mention quite a lot on this site, one of things I love about creating test cases is that you can use them over and over again.

Having a regression suite will allow you to spend less time developing test cases in the future and will also allow you to have a baseline of the system.

Please ensure that your post Test Execution housekeeping is done correctly to make your life easier for the future.

By that, I mean ensure you update the test cases before updating your regression test suite.


After writing this article, I have much more appreciation of vending machines and the technology that goes into them.

In fact, I’ll never look at them in the same way.

I thought that writing test cases for them would be quite straightforward but once I went down this rabbit hole, I realised how complex the subject can become.

Specialised vending machines that can dispense almost anything were particular interesting and this is exactly what will appeal to you as a Tester..

I hope you found this article as enjoyable as I did writing it.

The next time you ask yourself, “how would you test a vending machine?”…, hopefully you’ll remember this article.

Feel free to share with with other colleagues who you feel  may benefit from this.