Oct 14, 2020

API Testing 'A Beginners View': "Mockaroo" - A Cool Test Data Generator Tool

Recently, while working on a project I came across a need to generate data in bulk for testing purposes. So, it was then my team lead suggested the usage of the ‘Mockaroo tool’, which proved to be a hassle-free way to generate test data as and when required using REST API callouts. 

In this post, you find details on:
  • How to create simple bulk mockup test data?
  • How to get the mockup data in postman to use as per your need?
Prior to the start:
You should create an account in ‘Mockaroo’. (https://mockaroo.com/users/sign_in)
 
Here we go for the steps:
  1. Using the link shown above, register on ‘Mockaroo’. Once done, an API key will get generated for your account. This key will be used in all the API calls made to mockaroo. To know the API key, go to the Account page after logging in to Mockaroo.

  2. Once a ‘mockaroo’ account has been set up, create a schema for the entity under the ‘Schemas’ tab. Mockaroo has its own set of data types which is needed while creating fields for the schema. (We can import schema details such as the name of fields and data types using CSV headers or JSON to prevent human error) NOTE: For field names in the schema, we must use the same name as that of the API field name.
  3. On the launch of new schema creation, you will see some auto-populated fields provided by mockaroo as a sample, follow the same manner and start entering your fields as per need using the Mockaroo available datatypes. On the launch ‘Schema Creation Page’ look is as below:

  4. Available Data Types:

  5. Once the necessary fields are set up as per the API , save the schema.
  6. After save of schema mockaroo will generate a ‘curl url’, which will be the endpoint that needs to be used in your collection the postman as needed.

  7. Copy the url and use the GET method to call the test data generator url in your postman collection. 

  8. In order to use the test data fetched, set a variable either globally or environment to hold the test data, as below;

  9. Call the variable in the next POST request ‘Body’ for the endpoint you want the test data to be used and hit the send your data would be created in the requested endpoint;

Few known important things about MOCKAROO:
  • 3 subscriptions of mockaroo are available:
    • Free (200 API calls/day)
    • Silver (no limit to number of API Calls, 1 million records/day)
    • Gold (no limit to number of API calls, 10 million records/day)
  • Data Types used in mockaroo schemas are intrinsic to mockaroo and any other data type cannot be used.

No comments: