This page is no longer maintained — Please continue to the home page at www.scala-lang.org

ScalaCheck 1.5

Version 1.5 of ScalaCheck is now available. ScalaCheck is a tool for automatic unit testing of your Scala and Java programs, developed by Rickard Nilsson. ScalaCheck allows you to define general properties about your code units, while the tool handles all test data generation for you: you can run thousands of unit tests automatically without writing and maintaining an endless number of test cases. ScalaCheck started out as a Scala port of the Haskell library QuickCheck, and has since evolved and been extended with features not found in Haskell QuickCheck.

Version 1.5 of ScalaCheck introduces support for Scala 2.7.2 and various minor feature additions. Please visit http://www.scalacheck.org for change history, user guide, API reference and more.

ScalaCheck's highlights

  • Properties are tested automatically, with test data generated by ScalaCheck. Data generation can be precisely controlled, and generation of custom data types is simple to define.
     
  • Failing test cases are simplified automatically, which makes pin-pointing error causes easier.
     
  • Support for stateful testing of command sequences, and simplification of failing command sequences.
     
  • Property objects can be tested directly from the command line without any need for special test runners. You can also control different testing parameters from the command line.

A small example, using the Scala interpreter with ScalaCheck on the path:

scala> object StringProps extends org.scalacheck.Properties("String") {
     |   specify("startsWith", (a:String, b:String) =>
     |     (a+b).startsWith(a)
     |   )
     |   specify("substring", (a:String, b:String) =>
     |     (a+b).substring(a.length) == b
     |   )
     | }
defined module StringProps

scala> StringProps.check
+ String.startsWith: OK, passed 100 tests.
+ String.substring: OK, passed 100 tests. 

ScalaCheck links and information

sbaz update
sbaz install scalacheck

If you already have an earlier version of ScalaCheck installed, you just need to run:

sbaz upgrade
<repositories>
   <repository>
     <id>scala-tools.org</id>
     <name>Scala-Tools Maven2 Repository</name>
     <url>http://scala-tools.org/repo-releases</url>
   </repository>
</repositories>

<dependency>
  <groupId>org.scalacheck</groupId>
  <artifactId>scalacheck</artifactId>
  <version>1.5</version>
</dependency>

 

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland