by Daniel Sebban

Beyond unit tests: an intro to property and law testing in Scala

Taking your unit tests to the next level.

I have been using ScalaCheck testing library for at least 2 years now. It allows you to take your unit tests to the next level.

You can do Property-based testing by generating a lot of tests with random data and asserting properties on your functions. A simple code example is described below.

You can do Law testing that is even more powerful and allows you to check mathematical properties on your types.