User Guide

Contact information and license

PropEr (PROPerty-based testing tool for ERlang) is a QuickCheck-inspired open-source property-based testing tool for Erlang, developed by Manolis Papadakis, Eirini Arvaniti and Kostis Sagonas. The base PropEr system was written mainly by Manolis Papadakis, and the stateful code testing subsystem by Eirini Arvaniti.

You can reach PropEr's developers in the following ways:

We welcome user contributions and feedback (comments, suggestions, feature requests, bug reports, patches etc.).

Copyright 2010-2013 by Manolis Papadakis, Eirini Arvaniti and Kostis Sagonas.

This program is distributed under the GPL, version 3 or later. Please see the COPYING file for details.

Introduction

Traditional testing methodologies essentially involve software testers writing a series of test inputs for their programs, along with their corresponding expected outputs, then running the program with these inputs and observing whether it behaves as expected. This method of testing, while simple and easy to automate, suffers from a few problems, such as:

Property-based testing is a novel approach to software testing, where the tester needs only specify the generic structure of valid inputs for the program under test, plus certain properties (regarding the program's behaviour and the input-output relation) which are expected to hold for every valid input. A property-based testing tool, when supplied with this information, should randomly produce progressively more complex valid inputs, then apply those inputs to the program while monitoring its execution, to ensure that it behaves according to its specification, as outlined in the supplied properties.

Here are a few examples of simple properties a user may wish to test, expressed in natural language:

PropEr is such a property-based testing tool, designed to test programs written in the Erlang programming language. Its focus is on testing the behaviour of pure functions. On top of that, it is equipped with two library modules that can be used for testing stateful code. The input domain of functions is specified through the use of a type system, modeled closely after the type system of the language itself. Properties are written using Erlang expressions, with the help of a few predefined macros.

PropEr is also tightly integrated with Erlang's type language:

Quickstart guide

Where to go from here

To get started on using PropEr, see the tutorials and testing tips provided on PropEr's home page. On the same site you can find a copy of PropEr's API documentation (you can also build this from source if you prefer, by running make doc), as well as links to more resources on property-based testing.

Common problems

Using PropEr in conjunction with EUnit

The main issue is that both systems define a ?LET macro. To avoid a potential clash, simply include PropEr's header file before EUnit's. That way, any instance of ?LET will count as a PropEr ?LET.

Another issue is that EUnit captures standard output, so normally PropEr output is not visible when proper:quickcheck() is invoked from EUnit. You can work around this by passing the option {to_file, user} to proper:quickcheck/2. For example:

   ?assertEqual(true, proper:quickcheck(your_mod:some_prop(), [{to_file, user}]).

This will make PropEr properties visible also when invoked from EUnit.

Incompatibilities with QuviQ's QuickCheck

PropEr's notation and output format has been kept quite similar to that of QuviQ's QuickCheck in order to ease the reuse of existing testing code written for that tool. However, incompatibilities are to be expected, since we never run or owned a copy of QuviQ's QuickCheck and the two programs probably bear little resemblance under the hood. Here we provide a nonexhaustive list of known incompatibilities: