JFairy Test Data Generator for Test Cases - Bug Reaper

                  Bug Reaper

Lean about Automation Testing,Selenium WebDriver,RestAssured,Appium,Jenkins,JAVA,API Automation,TestNG,Maven, Rest API, SOAP API,Linux,Maven,Security Testing,Interview Questions

Sunday, 19 April 2020

JFairy Test Data Generator for Test Cases



Fairy can also create below objects & produce test data.

Person (See the example below)
Credit Card (CC Vendor, Expiry etc)
Network (IP address and random URLs)
Company (name, email, domain etc)
Date (Random dates in past, future, range)
Text (Random word, text, paragraph etc)


package seleniumNew;

import java.util.Locale;

import io.codearte.jfairy.Fairy;
import io.codearte.jfairy.producer.DateProducer;
import io.codearte.jfairy.producer.company.Company;
import io.codearte.jfairy.producer.company.CompanyProperties.CompanyProperty;
import io.codearte.jfairy.producer.company.CompanyProvider;
import io.codearte.jfairy.producer.payment.CreditCard;
import io.codearte.jfairy.producer.person.Person;
import io.codearte.jfairy.producer.text.TextProducer;

public class TestDataUsingJFairy {

public static void main(String[] args) {
Fairy fairy=Fairy.create();

Person person = fairy.person();

System.out.println(person.getFullName());
System.out.println(person.getAddress());
System.out.println(person.getCompanyEmail());
System.out.println(person.getNationalIdentificationNumber());
System.out.println(person.getUsername());
System.out.println(person.getDateOfBirth());
System.out.println(person.getCompany());
System.out.println(person.getPassportNumber());

CreditCard creditCard=fairy.creditCard();
System.out.println(creditCard.getExpiryDateAsString());
System.out.println(creditCard.getVendor());
System.out.println(creditCard.getExpiryDate());

TextProducer textProducer=fairy.textProducer();

System.out.println(textProducer.latinSentence(10));
System.out.println(textProducer.paragraph());
System.out.println(textProducer.randomString(10));
System.out.println(textProducer.sentence(15));
System.out.println(textProducer.loremIpsum());


CompanyProperty companyProperties = new CompanyProperty() {

@Override
public void apply(CompanyProvider company) {
// TODO Auto-generated method stub

}
};
Company company=fairy.company(companyProperties);

System.out.println(company.getUrl());
System.out.println(company.getVatIdentificationNumber());
System.out.println(company.getDomain());
System.out.println(company.getEmail());

DateProducer dateProducer=fairy.dateProducer();

System.out.println(dateProducer.randomDateInTheFuture(10));

//Creating Data for France Local
Fairy frFairy = Fairy.create(Locale.forLanguageTag("fr"));

Person person1 = frFairy.person();

System.out.println(person1.getFullName());
System.out.println(person1.getAddress());
System.out.println(person1.getCompanyEmail());
System.out.println(person1.getNationalIdentificationNumber());
System.out.println(person1.getUsername());
System.out.println(person1.getDateOfBirth());
System.out.println(person1.getCompany());
System.out.println(person1.getPassportNumber());
}

}


No comments:

Post a Comment