我有一个包含250个字段的案例类:
<C99><F1>
有没有办法使用scala check为其参数生成值
我看过的无关紧要的问题:
How to generate case objects for every field in a Scala case class using macro?
Dynamically generate case class in Scala
Create an Arbitrary instance for a case class that holds a `Numeric` in ScalaCheck?
答案 0 :(得分:3)
import org.scalacheck.Shapeless._
import org.scalacheck.Arbitrary._
implicitly[Arbitrary[Data]]
以上代码段执行以下操作:
shapeless.Generic[Data]
将案例类转换为shapeless.HList
Arbitrary[String]
,Arbitrary[Int]
等等Arbitrary[Data]
实例