Yet another way to incorporate dummy data for testing your apps

While testing your app, it is not uncommon to create some temporary object to demo with…

This basic example of dummy data, or as Wikipedia defines it as, “benign information that does not contain any useful data, but serves to reserve space where real data is nominally present”, can quickly become more cumbersome as you require more variation in your model objects.

You may already be familiar with (and tired of) initializing your class models with similar syntax as above. The above example works when you may only have to initialize one object with one attribute to test with, but what happens when you have to work with multiple models that accept multiple attributes?

Say we have a User class and a Post class with their respective tables in a database…

When you’re ready to test your models out, you type your starter data in the seeds file (in this case, in a Ruby on Rails project) as such…

You can imagine initializing more than one of these might prove to be a lot of work, especially if you’re testing front-end and want as similar as possible to real data to display. Faker.js, or the Faker gem for ruby is one of the easiest ways to incorporate and use. However, there is another alternative that requires just a few more steps to work with, but all it is is just entering your specifications in a form.

Mockaroo is a website where you can easily generate fake data and import it into your project…

Generated data can include names, dates, locations, domain names, email addresses, and even bitcoin addresses. The site allows you to download your file as json, csv and others, as well as json with attributes compatible to firebase and it’s NoSQL database, which, autogenerates id’s (like “-MUJOdTlP46FAa2x1LUp”) that can be difficult to work with at times.

This is my first blog. If you’ve learning anything, or have ideas for further topics, feel free to comment below. I will try to post helpful and brief bits of knowledge more unique and engaging in the future!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store