My scalatest scalacheck flow
Introduction
- I start with generating
simple valuesrequired for myclass hierarchy, In this phase I generateLongDoublevalues. - I move forward to create
generatorsfor more complexcase classes. - I create
Listsof thesecase classes. - Finished modeling the
data structuresmoving on to using them intests!
Generate simple class
Generate simple class frequencies
- Defined relative frequencies for arbitrary generated
longsand forLong.MaxValuein this case20/1
Generate a complex class
- We used the
forcomprehension and in eachiterationwe callArbitrary(somegen).arbitraryto get an ..arbitraryvalue we use this arbitrary value in order toyieldour requesteddata structure.
General list of objects
Now that we know how to generate our case class lets generate a list of it.
we created a new generator, our new generator is calling Gen.containerOf[List, OurType] and passing as its argument our single case class generator.