summaryrefslogtreecommitdiff
path: root/assignments/assignment3/assignment3.tex
blob: ec64ee772a375973fc10647b44e657496ff288f8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
\documentclass[british]{scrartcl}

\usepackage[british]{babel}
\usepackage{csquotes}
\usepackage{enumerate}
\usepackage[hidelinks]{hyperref}
\usepackage{minted}
\setminted{fontsize=\small,breaklines,breakanywhere,tabsize=4}
\newmintinline[hs]{haskell}{style=bw}
\usepackage{caption}
\newenvironment{longlisting}{\captionsetup{type=listing}}{}
\usepackage{tikz}
\usetikzlibrary{arrows, matrix, positioning}
\usepackage{cleveref}

\let\oldurl\url
\def\url#1{{\small\oldurl{#1}}}

\title{Model-Based Testing with QuickCheck}
\subtitle{Testing \texttt{chesshs} with QuickCheck}
\author{Ren\'e den Hertog \and Camil Staps \and Erin van der Veen}

\begin{document}

\maketitle

\section{QuickCheck}
QuickCheck\footnote{\url{http://www.cse.chalmers.se/~rjmh/QuickCheck/}} is a property based testing tool initially created for Haskell.
Given that our SUT is a Haskell library and that QuickCheck is recommended in the assignment, using QuickCheck is nothing but a logical consequence.

\section{Modelling}
We decide to test the move verification functionality and not the parser.
The reason for this is that the parser is less well-defined, as we saw in our previous assignment.
Also, it seems relatively easy to break the parser, so we would prefer to fix the obvious problems before applying automated testing.
Lastly, the move verification functionality is more interesting because of the larger search space and complexity.

As mentioned above, QuickCheck is a property based testing tool.
A property based testing tool can test if certain specifications (a list of properties) of a program/function hold.
This is done through generating a large sample of test cases.

In QuickCheck, test cases are generated with the \hs{Arbitrary} class.
This class implements has two members, \hs{arbitrary :: Gen a} and \hs{shrink :: a -> [a]}.
The first generates random, usually large, test cases.
When a counter-example is found, QuickCheck uses \hs{shrink} to find a minimal counter-example by shrinking the known counter-example while preserving the inconsistency.

The above implies that a model of the system is given using a specification.
In our case, the model is a collection of predicates which should hold.
We compile a test program with \texttt{chesshs} and QuickCheck and run it.
So, unlike in assignment 1, we do not use a wrapper.

\end{document}