TestCasesGuidelines

This page gives a full explanation of how test cases are treated in order to get executed automatically.

Overview

In order to enable the test cases to be executed automatically a couple of constraints must be respected.

That's what the automatic test procedure does:

  1. The code marked up as test case in a given phrase page is extracted.
  2. The expression r← as added to to front of the headline in order to make the test function return a result.

  3. The line that contains the expression ⍝ ---- Start Test cases is located.

  4. After that line the expression r←⍬ is inserted as a new, additional line.

  5. All subsequent lines that contain the (match) symbol are prefixed by r,←.

  6. The function is executed in Dyalog APL.

As a result of that the function returns a vector of Booleans with a 1 for success and a 0 for failure. The length depends on the number of test cases. If there is at least one 0, the according test case is reported as faulty.

Of course all errors that might occur during the course of action are trapped. If such an error occurs the page is reported accordingly with a complete failure of the test cases.

What to Avoid

That's it - not too complicated.

Who, when, where

An Example

This is a test case from the LeapYear page:

Test
 ⎕IO←0      ⍝ You may change this; however, zero IS the default in the Phrasebook
⍝⎕ML←3      ⍝ Enable this line in Dyalog APL if appropriate
 ⎕FX'r←LeapYear ia' 'r←0≠.=4 100 400∘.|ia'
⍝ ---- Start Test cases (do not delete this!)
 im←1900 2000 2100∘.+¯4 ¯1 0 1 4
 (3 5⍴1 0 0 0 1 1 0 1 0 1)≡LeapYear im
 leapyrs←(LeapYear yrs)/yrs←1753+⍳50
 (1756+4×⍳11)≡leapyrs
 leapcent←(LeapYear cent)/cent←100×16+⍳24
 (1600+400×⍳6)≡leapcent

Before it gets finally executed, this code is transformed into this:

r←Test
 ⎕IO←0      ⍝ You may change this; however, zero IS the default in the Phrasebook
⍝⎕ML←3      ⍝ Enable this line in Dyalog APL if appropriate
 ⎕FX'r←LeapYear ia' 'r←0≠.=4 100 400∘.|ia'
⍝ ---- Start Test cases (do not delete this!)
 r←⍬
 im←1900 2000 2100∘.+¯4 ¯1 0 1 4
 r,←(3 5⍴1 0 0 0 1 1 0 1 0 1)≡LeapYear im
 leapyrs←(LeapYear yrs)/yrs←1753+⍳50
 r,←(1756+4×⍳11)≡leapyrs
 leapcent←(LeapYear cent)/cent←100×16+⍳24
 r,←(1600+400×⍳6)≡leapcent


CategoryPhraseBookBackground

PhraseBook/TestCasesGuidelines (last edited 2010-12-11 09:11:57 by KaiJaeger)