Subscribe to our Erlang Factory newsletter to receive the latest updates and news

Hans Svensson
Proud member of the ProTest project
Quviq AB and Chalmers University of Technology

Hans Svensson is researcher with eye for applying new technology in practice. He has been using QuickCheck ever since he got in touch with it and actively helps in developing the tool further. He is a post-doc at Chalmers involved in the EU project ProTest and working for Quviq part of his time. Hans PhD thesis is worth reading for people that wonder whether the gen_leader is tested well enough.

Hans Svensson is Giving the Following Talks
Tutorial: Testing concurrent software with QuickCheck

Testing software is difficult, testing concurrent software seems almost impossible. Just writing a test case for a concurrent program is a challenge, since one may have a number of different correct executions that result in different, but all correct results. 

Quviq QuickCheck is an automated testing tool that can be used to automatically generate test cases. In traditional testing, one often writes a sequence of operations to be executed and that sequence is tested. Running the commands in that sequence in parallel is far harder, since how would the test case look like?  QuickCheck specification also often start from specifying sequential execution of possible sequences; but QuickCheck can run the commands in the sequence in parallel and the specification can be used to validate the outcome of such a run. All that, fully automatically.
In this way, testing the Erlang OTP dets module becomes possible.

PULSE is an addition to QuickCheck that enables you to find concurrency errors like race conditions and deadlocks in Erlang programs. Even if those errors may not show on a single processor system, they may be sitting there waiting to be revealed when you switch to multi-core. With PULSE you explore random schedulings that are possible on a multi-core but not on a single core, therewith increasing the possibility to reveal weird errors. Of course, the test case is minimized when finding a concurrency error, which results in a repeatable test case that helps to analyze the cause of the error quickly.

In this tutorial some knowledge of QuickCheck is required; it suffices if you participated in a QuickCheck talk or tutorial before. We will look at a few examples in which QuickCheck and PULSE are used to find concurrency errors.

Tutorial: QuickCheck Mini

QuickCheck support property based development. Instead of writing test cases for your applications, you write a one-pager with a QuickCheck property from which hundreds of test cases are generated
automatically. QuickCheck simplifies failing cases to a minimal example on a test failure (so that fault diagnosis is quick and easy). QuickCheck enables developers to dramatically improve test coverage, and find obscure errors at an earlier stage, lowering costs and improving quality as a result.

In this tutorial we will look at QuickCheck Mini, the free version of the QuickCheck library, and use examples to show how developers write QuickCheck specifications—which are actually Erlang programs using the QuickCheck API—and use them to test code written in Erlang or other programming languages. We will show how QuickCheck’s shrinking finds tiny examples that provoke errors, making the step from observing a bug to diagnosing it very short indeed, and we will show how property driven development can produce code that is solid from the word go.