My scalatest scalacheck flow

Introduction

  1. I start with generating simple values required for my class hierarchy, In this phase I generate Long Double values.
  2. I move forward to create generators for more complex case classes.
  3. I create Lists of these case classes.
  4. Finished modeling the data structures moving on to using them in tests!
Generate simple class
Generate simple class frequencies
  • Defined relative frequencies for arbitrary generated longs and for Long.MaxValue in this case 20/1
Generate a complex class
  • We used the for comprehension and in each iteration we call Arbitrary(somegen).arbitrary to get an .. arbitrary value we use this arbitrary value in order to yield our requested data 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.

comments powered by Disqus