Generation of random data for tests

790 Views Asked by At

In Java, I can do things with EasyRandom

final EasyRandom generator = new EasyRandom();
final MyDto dummy = generator.nextObject(MyDto.class);
// test

But I haven't found a suitable way to do something like this in Kotlin

Which libraries should be used to create fake test data?

1

There are 1 best solutions below

0
AndreRatzenberger On BEST ANSWER

I like KotlinFixture.

You can do things like this with it

val randomElement = fixture(listOf(<your objects>))

and other fake data generation.

https://github.com/appmattus/kotlinfixture