Java fake data generator. According to Wikipedia:
Fairyland, in folklore, is the fabulous land or abode of fairies or fays.
Add the following dependency to your pom.xml:
<dependency>
<groupId>com.devskiller</groupId>
<artifactId>jfairy</artifactId>
<version>0.8.2</version>
</dependency>Fairy fairy = Fairy.create();
Person person = fairy.person();
System.out.println(person.getFirstName());
// Chloe
System.out.println(person.getLastName());
// Barker
System.out.println(person.getEmail());
// barker@yahoo.com
System.out.println(person.getTelephoneNumber());
// 690-950-802
System.out.println(person.getJobTitle());
// Software Developer
Person adultMale = fairy.person(PersonProperties.male(), PersonProperties.minAge(21));
System.out.println(adultMale.isMale());
// true
System.out.println(adultMale.getDateOfBirth());
// at least 21 years earlierFairy fairy = Fairy.create();
Company company = fairy.company();
System.out.println(company.getName());
// Robuten Associates
System.out.println(company.getUrl());
// http://www.robuteniaassociates.com
Person salesman = fairy.person(PersonProperties.withCompany(company));
System.out.println(salesman.getFullName());
// Juan Camacho
System.out.println(salesman.getCompanyEmail());
// juan.camacho@robuteniaassociates.com| Locale | Language tag |
|---|---|
| English (default) | en |
| Polish | pl |
| German | de |
| French | fr |
| Spanish | es |
| Swedish | sv |
| Chinese | zh |
| Georgian | ka |
| Italian | it |
| Brazilian Portuguese | br |
| Slovak | sk |
| Turkish | tr |
Fairy enFairy = Fairy.create();
// Locale.ENGLISH is default
Fairy plFairy = Fairy.create(Locale.forLanguageTag("pl"));
// Polish version
Fairy brFairy = Fairy.create(Locale.forLanguageTag("br"));
// Brazilian versionUniqueFairy unique = fairy.unique();
Person p1 = unique.person(); // unique by email
Person p2 = unique.person(); // different email than p1
Company c = unique.company(); // unique by nameFor custom uniqueness keys:
UniqueEnforcer<Person> unique = UniqueEnforcer.of(fairy::person, Person::getFullName);
Person p = unique.next();Fairy objects are not designed for concurrent use by multiple threads.
It is recommended to create a separate Fairy instance for each thread.
While some methods might appear safe, the underlying Random implementation can lead to contention and poor performance. Creating dedicated instances ensures both thread safety and optimal execution speed.
If you use JUnit 5, check out jfairy-junit-extension — an extension that allows injecting jFairy-generated objects directly into test method parameters.
This project uses Maven and can be built using the provided wrapper:
./mvnw