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

Solution 1:

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.

Solution 2:

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

Solution 3:

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