diff options
-rw-r--r-- | assignments/assignment1.tex | 21 | ||||
-rw-r--r-- | test/runtests.sh | 15 | ||||
-rwxr-xr-x | test/test.sh | 18 |
3 files changed, 37 insertions, 17 deletions
diff --git a/assignments/assignment1.tex b/assignments/assignment1.tex index f108eee..9f9e7e8 100644 --- a/assignments/assignment1.tex +++ b/assignments/assignment1.tex @@ -272,11 +272,28 @@ Since Haskell, as most functional programming languages, is ``stable" in terms o \section{Manual Testing} -% TODO : Add the "results" of the exercises of section 2 of the assignment. +Since the SUT is an Application Programming Interface all tests are constructed not as an sequence of interactions, but rather as something that can be fed to the wrapper. +In turn, the wrapper uses the API of \texttt{chesshs} to construct the position sequence. +This position sequence is then compared to a user defined expected output. + +In essence, this implies that the Manual Tests and Automated Tests are the same. + +If the wrapper were extended to support interactivity, manual testing would have a more prominent place. \section{Automated Testing} -% TODO : Add the "results" of the exercises of section 3 of the assignment. +The input of the automated tests are stored in individual files. +These files contain one or more PGN games that are fed to the wrapper. +The wrapper then passes these PGN games to the chesshs library, and outputs the board state after every move. +\begin{listing} + \inputminted{bash}{../test/test.sh} + \caption{Automated Test script} + \label{L:ATS} +\end{listing} + +A small bash script~\ref{L:ATS} is used to compare the output that is produced by the wrapper with a user defined expected output. +If there is no difference between the two, the test is considered \enquote{Passed}. +If there is a difference, this is output by the script. \begin{thebibliography}{8} \bibitem[C] {C} \url{http://haskell.org/cabal} diff --git a/test/runtests.sh b/test/runtests.sh deleted file mode 100644 index e9a54c6..0000000 --- a/test/runtests.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash -RED='\033[0;31m' -GREEN='\033[0;32m' -RESET='\033[0;30m' - -for f in database/*.in; -do - output=$(diff "${f/in/out}" <(../src/runchess < "$f")) - if [ "$output" = "" ] - then - echo -e "${GREEN}Test $(basename $f .in) passed${RESET}" - else - echo -e "${RED}Test $(basename $f .in) failed${RESET}" - fi -done diff --git a/test/test.sh b/test/test.sh new file mode 100755 index 0000000..17728aa --- /dev/null +++ b/test/test.sh @@ -0,0 +1,18 @@ +#!/bin/bash +RED='\033[0;31m' +GREEN='\033[0;32m' +RESET='\033[0;30m' + +for f in database/*.in; +do + output=$(diff "${f/in/out}" <(../src/runchess < "$f")) + testname=$(head -1 $f | cut -d \" -f 2) + if [ "$output" = "" ] + then + echo -e "${GREEN}Test: \"$testname\" passed${RESET}" + else + echo -e "${RED}Test: \"$testname\" failed${RESET}" + diff --suppress-common-lines -y -W 50 "${f/in/out}" <(../src/runchess < "$f") + fi + echo "############################################" +done |