I would like to know if a fake data generator exists for Java. In Perl exists Data::Faker
and there's a port to Ruby called faker
, for JavaScript faker.js
. Someone know about a fake data generator for Java, that can provide random names, phone number, P.O. box number, etc...
Automation Testing Interview Help, Java, Test Automation / July 15, 2021 July 15, 2021 / 16 Comments. Java Faker is a library used to generate fake data. It provides different classes and methods in order to generate real-looking data that ranges from mobile number, address, music, nation and many more.
Try jFairy. This is new project in early stage.
Fairy fairy = Fairy.create();
Person person = fairy.person();
System.out.println(person.fullName()); // Chloe Barker
System.out.println(person.email()); // [email protected]
System.out.println(person.telephoneNumber()); // 690-950-802
Company company = fairy.company();
System.out.println(company.name()); // Robuten Associates
System.out.println(company.url()); // http://www.robuteniaassociates.com
Person salesman = fairy.person(withCompany(company));
System.out.println(salesman.fullName()); // Juan Camacho
System.out.println(salesman.companyEmail()); // [email protected]
PS. I'm a contributor.
http://www.andygibson.net/blog/article/generate-test-data-with-datafactory/ How to use:
Add it in your pom.xml
<dependency>
<groupId>org.fluttercode.datafactory</groupId>
<artifactId>datafactory</artifactId>
<version>0.8</version>
<type>jar</type>
</dependency>
Test it...
public class Main {
public static void main(String[] args) {
DataFactory df = new DataFactory();
for (int i = 0; i < 100; i++) {
String name = df.getFirstName() + " "+ df.getLastName();
System.out.println(name);
}
}
}
Output :
Lindsey Craft
Erica Larsen
Ryan Levine
Erika Smith
Brooklyn Sloan
Karen Mayer
Eddie O'neill
Nancy Stevens
There is a Java port of the Perl Data::Faker - java-faker
If you're using Hibernate, try HibernateMock.
Also:
ThinkUI
Benerator
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With