How to Mock Data with Mockaroo

Mockaroo-1080x630.jpg

1. Why Mockaroo?

Need some mock data to test your app? Mockaroo lets you generate up to 1,000 rows of realistic test data in CSV, JSON, SQL, and Excel formats.

Why is test data important?

If you're developing an application, you'll want to make sure you're testing it under conditions that closely simulate a production environment. In production, you'll have an army of users banging away at your app and filling your database with data, which puts stress on your code. If you're hand-entering data into a test environment one record at a time using the UI, you're never going to build up the volume and variety of data that your app will accumulate in a few days in production. Worse, the data you enter will be biased towards your own usage patterns and won't match real-world usage, leaving important bugs undiscovered.

Why is realistic data important?

When your test database is filled with realistic looking data, you'll be more engaged as a tester. When you demonstrate new features to others, they'll understand them faster. Real data is varied and will contain characters that may not play nice with your code, such as apostrophes, or unicode characters from other languages. Testing with realistic data will make your app more robust because you'll catch errors that are likely to occur in production before release day.

Why Mockaroo?

There are plenty of great data mocking libraries available for almost every language and platform. But not everyone is a programmer or has time to learn a new framework. Mockaroo allows you to quickly and easily to download large amounts of randomly generated test data based on your own specs which you can then load directly into your test environment using SQL or CSV formats. No programming is required.

Want to automate test data generation?

If you sign in using your Google account, you can download random data programmatically by saving your schemas and using curl to download data in a shell script via a RESTful url.

Data Types

Screen Shot 2018-03-21 at 10.47.23.png

2. How to use Mockaroo?

Step 1: Create a Schema

Use Mockaroo's data designer to design a format for the response

schema-ff31c65e6759f94969eeda5c40efd6aca67d48b8b41e42f3ba89ab520ba560c0.png

Step 2: Create a Mock API

Define a URL and specify how the response is generated. You can map incoming request parameters to parameters in your schema, augment generated data with static values, conditionally return an error, or simply return a static data using Mockaroo's Ruby API.

api-7387de46a4fbe2dbcdfb1aca5637d68d0bd4aa3a6ff0e395cfff0869dd938b37.png

 

Step 3: Fetch Data

Start sending requests using the client library of your choice. Here's an example using JavaScript.

Screen Shot 2018-03-21 at 10.53.10.png