Desk test

from Wikipedia, the free encyclopedia

The desk test is a method in the field of software development , is used to algorithms or routines to check for accuracy. The desk test is not carried out with the help of a computer, but rather in the developer's mind. To this end, an input and a possible output quantity are specified for a deterministic and terminating program flow. The correctness of the program sequence is then checked with each element of the input set by means of step-by-step calculations. The selected program sequence behaves correctly for the selected input element if the output element, i.e. the result, is part of the output quantity.

The fact that the input set for an algorithm can be arbitrarily large, e.g. B. a subset of the natural numbers requires the developer to check the correctness of the program to be tested step by step with all elements of the input set. If there is no upper or lower limit for the input quantity, then the desk test can at most provide an indication that the algorithm has been implemented correctly with a few plausible inputs.

The prerequisites for the desk test are a deterministic and terminating program sequence, knowledge of plausible and meaningful input elements, and knowledge of the output elements that match the input elements in order to be able to deduce the correctness from the respective output. The result for the respective input must therefore be known.

Example: potency

A desk test is to be carried out for the following Pascal function:

1  function nHochM(n,m:integer);
2  var i:integer;
3  var produkt:integer;
4  begin
5   if m=0 then nHochM:=1 else
6   if m=1 then nHochM:=n else
7   begin
8    produkt:=n;
9    for i:=2 to m do
10    produkt:=produkt*n;
11   nHochM:=produkt;
12  end;
13 end;

Calculation of 2 3 :

row i product condition
5 false
6th false
8th 2
9 2 2 true (loop is executed)
10 2 4th
9 3 4th true
10 3 8th
9 3 8th false