ScalaCheck in ScalaTest

Today I held a presentation at the Scala Community at my employer about ScalaCheck. ScalaCheck is a property based testing tool, which allows you to specify properties using predicates such as: \( \forall s : s.reverse.reverse \equiv s \), which denotes that for all Strings s when you reverse s twice it should equal the original s.

Please see the Slides, which are created using the nice RevealJS.

Maybe even more interesting are the code examples which can be found in the code folder of my github repo for the presentation. There are a couple of files with accompanying tests. PropertiesTest.scala shows the ScalaCheck way of writing an executable test file which checks properties. ReverseExampleTest.scala contain some simple properties using ScalaTest’s GeneratorDrivenPropertyChecks, which using ScalaCheck under the hood. IbanExampleTest.scala contains a more interesting example where an implementation that calculates IBANs from old bank account numbers is tested.

tags:
blog comments powered by Disqus