Skip to content

implmnt/scalacheck-magnolia

Repository files navigation

scalacheck-magnolia

Derivation of scalacheck Arbitrary on magnolia

Build Status Maven Central

Usage

Add to your build.sbt

libraryDependencies += "im.plmnt" %% "scalacheck-magnolia" % "1.0.0" % Test

Can be used for case classes and/or sealed traits

sealed trait Foo
case class Bar(str: String, bool: Boolean) extends Foo
case object Baz extends Foo

For automatically derivation, import the content of scalacheck.magnolia.auto

import scalacheck.magnolia.auto._

forAll { foo: Foo =>
// Ensure foo has the required property
}

forAll { bar: Bar =>
// Ensure bar has the required property
}

For semi-automatically derivation use scalacheck.magnolia.semiauto

import scalacheck.magnolia.semiauto._

implicit val arbitraryForFoo: Arbitrary[Foo] = deriveMagnoliaArbitrary[Foo]

forAll { foo: Foo =>
// Ensure foo has the required property
}