generating test data
The longevity context provides a tool for producing test data:
val generator = longevityContext.testDataGenerator
You can construct test data with the generateP
method by supplying the type of the persistent
object that you want to generate:
val user: User = generator.generateP[User]
All members are filled in with random values. For example, a Boolean
will be true
about half the
time, and false
about half the time. Options
are non-empty about half the time. Sets
and
Lists
have vary in size from 0 on up. Strings are composed of 12 random alphanumeric characters.
Currently, you can use the generator to generate persistent components, Ints
and Strings
. For
instance:
val sampleInt = generator.generateInt
val sampleString = generator.generateString
In the future, we will probably expand the TestDataGenerator
to generate more data types.