Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make testing code less verbose with specs2 #4805

jisantuc opened this issue Mar 27, 2019 · 0 comments


1 participant
Copy link

commented Mar 27, 2019

Problem description

We've had (at least, but I'll focus on) two usability problems with our scalacheck / scalatest strategy:

  • super verbose expectations -- to specify that a subset of fields on a large case class should be equal, we write assertions for each of the fields individually (for example)
  • poor integration between scalatest / scalacheck how we've written things -- we can't return scalatest assertions from our scalacheck properties, so we end up with a wall of assertions and then a true at the end of the functions we're testing (for example)

But what if I told you... there's another way.

Specs2 scalacheck integration seems like it addresses both of these issues.

  • case class projection will let us define the expected fields in a new case class, project the result into the new case class, and handle all the equality checks with a single must_==
  • prop from specs2 doesn't care if we return booleans or MatchResults, which is great, because MatchResults are where we get nice error messages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.