Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does a fake data generator exists in Java? [closed]

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...

like image 839
Rubens Mariuzzo Avatar asked Jun 15 '11 18:06

Rubens Mariuzzo


People also ask

What is javafaker?

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.


4 Answers

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.

like image 106
MariuszS Avatar answered Oct 16 '22 07:10

MariuszS


http://www.andygibson.net/blog/article/generate-test-data-with-datafactory/ How to use:

  1. Add it in your pom.xml

    <dependency>
        <groupId>org.fluttercode.datafactory</groupId>
        <artifactId>datafactory</artifactId>
        <version>0.8</version>
        <type>jar</type>
    </dependency>
    
  2. 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
like image 16
sgl Avatar answered Oct 16 '22 08:10

sgl


There is a Java port of the Perl Data::Faker - java-faker

like image 15
Dmytro Chyzhykov Avatar answered Oct 16 '22 07:10

Dmytro Chyzhykov


If you're using Hibernate, try HibernateMock.

Also:

  • ThinkUI

  • Benerator

like image 7
Tony the Pony Avatar answered Oct 16 '22 08:10

Tony the Pony