My scalatest scalacheck flow
Introduction
- I start with generating
simple values
required for myclass hierarchy
, In this phase I generateLong
Double
values. - I move forward to create
generators
for more complexcase classes
. - I create
Lists
of thesecase classes
. - Finished modeling the
data structures
moving on to using them intests
!
Generate simple class
Generate simple class frequencies
- Defined relative frequencies for arbitrary generated
longs
and forLong.MaxValue
in this case20/1
Generate a complex class
- We used the
for
comprehension and in eachiteration
we callArbitrary(somegen).arbitrary
to get an ..arbitrary
value we use this arbitrary value in order toyield
our 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
.