How to easily create test objects / fixtures from data classes?

Hi everyone,

Sometimes while writing unit tests, I need to set up a lot of test data. Typically these are going to be for Kotlin data classes (or POJOs since there are still a lot of Java dependencies).

It can be tedious sometimes to set up all the test data, particularly when I’m trying to create an object that has many levels to it. Does anybody know of a good library to simplify the process of setting up test data? I’m looking for something along the lines of factory_girl or factory_bot in the Ruby on Rails world. Ideally something that will work with both Java and Kotlin classes.

1 Like

I’m not sure if it would suit your needs, but you could try this library: Property-based Testing | Kotest.