Need help with scalacheck-shapeless?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

alexarchambault
232 Stars 30 Forks Apache License 2.0 424 Commits 25 Opened issues

Description

Generation of arbitrary case classes / ADTs instances with scalacheck and shapeless

Services available

!
?

Need anything else?

Contributors list

# 21,607
sbt-plu...
scalajs
fp
jupyter
261 commits
# 4,857
scalajs
playfra...
akka-ht...
fp
68 commits
# 10,592
playfra...
scalajs
kafka
scalaz
5 commits
# 47,229
Shell
jvm-lan...
generic...
fp
3 commits
# 285,424
Scala
Shell
pretty-...
typelev...
3 commits
# 492,427
hadoop
Scala
Apache ...
kafka
1 commit
# 23,715
Scala
swagger
fp
typelev...
1 commit
# 188,808
Scala
Emacs
emacs-l...
fs2
1 commit
# 3,498
Scala
kafka
conflue...
mocking...
1 commit
# 3,278
imagema...
sass-fr...
splash
pipelin...
1 commit
# 93,794
Scala
playfra...
Shell
jvm-lan...
1 commit
# 43,424
Scala
apache-...
scala-j...
fp
1 commit

scalacheck-shapeless

Generation of arbitrary case classes / ADTs instances with scalacheck and shapeless

Build status Maven Central Gitter

Usage

Add to your

build.sbt
scala
libraryDependencies += "com.github.alexarchambault" %% "scalacheck-shapeless_1.15" % "1.3.0"

scalacheck-shapeless depends on shapeless 2.3 and scalacheck 1.15. It is built against scala 2.12, and 2.13.

Import the content of

org.scalacheck.ScalacheckShapeless
close to where you want
Arbitrary
type classes to be automatically available for case classes / sealed hierarchies, ```scala import org.scalacheck.ScalacheckShapeless._

// If you defined:

// case class Foo(i: Int, s: String, blah: Boolean) // case class Bar(foo: Foo, other: String)

// sealed trait Base // case class BaseIntString(i: Int, s: String) extends Base // case class BaseDoubleBoolean(d: Double, b: Boolean) extends Base

// then you can now do

implicitly[Arbitrary[Foo]] implicitly[Arbitrary[Bar]] implicitly[Arbitrary[Base]] ```

and in particular, while writing property-based tests,

scala
property("some property about Foo") {
  forAll { foo: Foo =>
    // Ensure foo has the required property
  }
}
without having to define yourself an
Arbitrary
for
Foo
.

See also

License

Released under the Apache 2 license. See LICENSE file for more details.

Code of Conduct

See the Code of Conduct

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.