Create Your own Dataset — Faker
Faker Library
Faker in python is used extensively to fill databases with some dummy data. Test data in test automation is one of the integral component and it is a pain to fill up this layer of test automation framework. With the use of faker library this problem can be easily solved , it generates large amount of data which looks very realistic and can be used to feed your test cases.
Let’s get started with installation of faker , The package is installed with composer.
pip install Faker
This command will let you download the necessary files required to use faker , post this import the library and create one object of faker class , below is the code snippet :
from faker import Faker
faker = Faker()
We can quickly see an example on how to fake names ,
print(f'name: {faker.name()}')
print(f'address: {faker.address()}')
print(f'text: {faker.text()}')
Run the python file
You can use faker object to create random data for your test cases as per your requirements. One advantage of using faker is , it quite allow you to generate data based up on the given locations to some extend . You can generate any kind of data which is required for the test cases , more on this can be read on the official documentation here.