This project was created by a developer from Ukraine. Russia has invaded Ukraine and already killed tens of thousands of civilians, with many more raped or tortured. The death toll keeps climbing. It's a genocide. We need your help. Let's fight back against the Russian regime. Russia has invaded Ukraine and already killed tens of thousands of civilians, with many more raped or tortured. It's a genocide. We need your help. Help Ukraine Now
kotlin-faker

kotlin-faker is a data-generation library intended for use during development and testing, as well as for data-anonymization purposes.
It generates realistically looking fake data within a variety of different domains such as names, addresses, banking details, movies, games, and many more. Just like this fake logo, but not quite so.


Some of the bits that kotlin-faker gives you are…

…a plethora of real-looking data in various domains:

val faker = Faker()
Names
faker.name.nameWithMiddle() // => Dr. John Abrams Smith
Addresses
faker.address.streetAddress() // => 474 Kilback Manor
Internet
faker.internet.safeEmail() // => chance.marvin@yahoo.test
Banking
val faker = CommerceFaker()
faker.bank.swiftBic() // => AACCGB21
Books
val faker = BooksFaker()
faker.book.genre() // => Fantasy
Movies and TV
val faker = MoviesFaker()
faker.starWars.characters() // => Darth Vader
val faker = TvShowsFaker()
faker.friends.characters() // => Phoebe Buffay
…and many others
// a total of 213 different data providers

…in 60 locales:

val config = fakerConfig { locale = "nb-NO" }
val faker = Faker(config)
nb_NO -> city
faker.address.city() // => Høyberg
nb_NO -> person‘s name
faker.name.nameWithMiddle() // => Sofie Ødegård Løken

…“unique data generation”:

val faker = Faker()
Generate unique values within a domain
faker.unique.configuration {
    // enable generation of unique values for address data provider
    enable(faker::address)
}
val countries = List(100) { faker.address.country() }
assertEquals(countries.distinct().size, 100)
Generate unique values within a function
val countries = List(100) { faker.address.unique.country() }
val cities = List(1000) { faker.address.city() }
assertEquals(countries.distinct().size, 100)
assertTrue(cities.distinct().size < 1000)

…cli native app for looking up data generators:

faker-bot lookup name --verbose
#Faker()
#├── address
#│   ├── cityName() // => Port Olinstad
#│   ├── countryByName() // => NR
#│   └── streetName() // => Lance Roads
#├── animal
#│   └── name() // => gnat
#├── app
#│   └── name() // => Bamity
#├── artist
#│   └── names() // => Cezanne
#├── bank
#│   └── name() // => ABN AMRO HOARE GOVETT SECURITIES
#├── beer
#│   └── name() // => Oaked Arrogant Bastard Ale
# rest of output that matches query

…and more:

val faker = Faker()
Random instance of any class…
class Foo(val a: String)
class Bar(val foo: Foo)

val foo: Foo = faker.randomClass.randomClassInstance()
val bar: Bar = faker.randomClass.randomClassInstance()
…with pre-configured type generation
class Baz(val id: Int, val uuid: UUID, val username: String)

val baz: Baz = faker.randomClass.randomClassInstance {
    // ヽ(^o^)丿 ᕕ(ᐛ)ᕗ Prepend string type parameter values with parameter name!
    typeGenerator<String> { parameterInfo -> "${parameterInfo.name}_${randomString()}" }
    typeGenerator<UUID> { UUID.fromString("00000000-0000-0000-0000-000000000000") }
    typeGenerator<Int> { faker.random.nextInt(min = 0, max = 9) }
}
assertEquals(baz.username, "username_X3a8s813dcb")
assertEquals(baz.uuid, UUID.fromString("00000000-0000-0000-0000-000000000000"))
assertTrue(baz.id in 0..9)
String templates
faker.string.numerify("foo###bar") // foo123bar
faker.string.letterify("foo???bar", true) // fooXYZbar
faker.string.bothify("foo?##bar", false) // foox42bar
faker.string.regexify("""\d{2}\w""") // 42a
Random numbers, strings, enums, UUIDs, and more…
faker.random.nextInt(intRange = 0..1000)
faker.random.nextLong(bound = 999L)
faker.random.randomString(length = 99)
faker.random.nextEnum<TestEnum>()
faker.random.nextEnum(TestEnum::class.java) {
    it != TestEnum.SOME // Exclude 'SOME' enum
}
faker.random.nextUUID()

See the pages under the User Guide section, jump straight to the Getting Started page, or explore the Data Provider API or the Full Core API documentation to learn more.