I'm working with a piece of code that has a broad/deep case class hierarchy. For unit testing, I'd like to have "random data" populated in the classes with the ability to change the data for the fields I care about?
Example:
case class Foo(bar: Bar, name: String, value: Int)
case class Bar(baz: Baz, price: Double)
case class Baz(thing: String)
So something like:
val randomFoo = GenerateRandomData(Foo)
randomFoo.bar.baz = Baz("custom for testing")
I've heard of ScalaCheck
and Shapeless
and Scalacheck-shapeless
and they do provide some sort of random data generation but nothing with customization it seems.
I'm currently using ScalaMock
but that builds out null
fields and breaks testability for "other" tests. I used something similar in .Net like Auto Fixture and was wondering if there was something similar in Scala.