Eyup - it's that Mark Smith!

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.

  1. Go to www.mockaroo.com. You'll see a display of field names a bit like the image below:

Shows field specifications in Mockaroo

  1. Hit the 'Preview' button at the bottom to see what your data is going to look like:

Web page showing a table of perxon data, including name, email, gender and IP address

  1. Add a field - name it city and choose the city data type:

City data type

The preview now shows cities from across the world. Handy but not targeted enough for my demo.

City column added to the preview

  1. 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.

Selecting a single country

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:

Data preview with city and country in agreement, but airport not

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.

  1. Add a 'first_order' date:

Add a date field and set the start and end dates

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.

Preview of final data

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.

#Data #Testing