Using Mockaroo to generate (quite) realistic data
How many times have you seen a test (or worse) a demo with data that looks like Customer1
, CustomerEmail@test.com
etc? Looks rubbish, doesn't it, so why not use something more realistic? In this post, I'm going to show you how to use a web site called Mockaroo to generate much more plausible data that will make your demos (and tests) shine.
The problem with using real data in tests and demos
Using anonymized 'real' customer data can be a hassle, especially getting permission to use it. Persuading your production colleagues to do a one-off export from 'Live' can and should be difficult, most likely involve conversations with the words 'legals', 'GDPR' and 'Governance', and possibly ending with 'Nah, no chance. Too busy'.
So why not just generate some bogus data, fresh when you need it? No meetings, no having to explain it to the legals folks, no delays. No risk of GDPR entanglements, especially if you maintain an audit trail of how you generated the data in the first place
What is Mockaroo and why use it?
Mockaroo - www.mockaroo.com is a web application you can use to generate scads of test data, of all kinds, in just a few clicks. I've used it at a number of customers - finance, pharmaceuticals and travel, without issue.
Getting started with Mockaroo
For a (fictitious) demo of a customer management page, I want somewhat realistic customer data, in the UK with the city they are in and when they first ordered from us.
- Go to www.mockaroo.com. You'll see a display of field names a bit like the image below:
- Hit the 'Preview' button at the bottom to see what your data is going to look like:
- Add a field - name it city and choose the city data type:
The preview now shows cities from across the world. Handy but not targeted enough for my demo.
- Add the Country data type:
Add a Country field and then choose 'Restrict countries' and choose 'United Kingdom'. After that Mockaroo will only start showing cities in the UK.
This is a handy feature, but it only works for some things. I tried it for airports as shown below but the country restriction did not carry over:
You need to be signed in to export your mock data, but once you are you can generate 1000 rows for free and export them to a range of formats including JSON or even SQL INSERT statements. You can do this as many times as you wish.
- Add a 'first_order' date:
Here, I've set the date to be blank 15% of the time to simulate customers who signed up but never ordered anything. I also removed the gender and IP fields as they aren't relevant.
That looks pretty close to real data, and would certainly pass muster for a demo or a more realistic test database setup.
There's a lot of other cool stuff Mockaroo can do including applying mathematical shaping to your data. I've used it to generate somewhat realistic numbers of adults, children and infants for holiday hotel searches for example.
The Mockaroo UI allows a lot of customization of your data. Under the hood it's a Ruby app, and it exposes some Ruby programming features that allow you to fine tune how the data is generated. The more effort you put in, the more realistic the outcome.