Test Data Generation Libraries

Hi all, 

I will give you some information about test data generator libraries to use in test project. If you ever developed automation code, you know that creating test data is a difficult task. There are any approach for test data generation:

    • Hard-coded data
    • Random data generation.
    • Data from production or test environment and do shuffling, etc

Characteristic of Test Data

Hard-coded data is mainly a bad choice because of uniqueness problems. For that reason random data generation might be a better fit.

Good test data must have below characteristics:

  • Meaningful
  • Consistent
  • Complete

Let’s think that we have to create a new user on an e-commerce website. We define a “male” user. This user might have below attributes:

Name: Bruce
Last Name: Wayne
Gender: Male
Age: 34
Birth City: Gotham

But what if you need to create a “female” user! You only need to change gender field. Am I right? Of course not, the data will be meaningless. You definitely need to change “name” because Bruce is a male name. You might get confused when you filter all female users and see “Bruce” in the list :) In case you don’t change the name according to the gender, you will have meaningless and sometimes inconsistent data in your system.

Those kinds of situation pushed me to look for a solution and I have found some libraries. Below libraries might be very easily integrated into your test automation projects developed with JAVA.

 I will share an examples of Jfairy libary. As you can see it’s very easy to integrate into your project.

Fairy fairy = Fairy.create();
Person person = fairy.person();

System.out.println(person.fullName());            
// Chloe Barker
System.out.println(person.email());               
// barker@yahoo.com
System.out.println(person.telephoneNumber());     
// 690-950-802

Person adultMale = fairy.person(male(), minAge(21));
System.out.println(adultMale.isMale());           
// true
System.out.println(adultMale.dateOfBirth());      
// at least 21 years earlier

Those ones can be used for Ruby projects.

Those two can be used for .NET projects

Nowadays many development teams started to migrate to Kotlin in their project as it offers flexibility compared to Java. In case you write automation code, here’s a great library. It supports many data models like Person, Bank,App, Movies etc…

These libraries can help you create many types of data like address, phone number (some libraries can create data according to Locale that you prefer), company, user, orders, etc…

A Final Tip

While choosing the right data generator look for consistency. If your user’s name is Peter Parker, his mail address should be peter.parker@blabla.com, not tony.stark@blabla.com

Some libraries provide that, some don’t.

May the good data be with you.

Thanks.
-Canberk

2 thoughts on “Test Data Generation Libraries”

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.