03.02 - Phases

Test case script

As we have seen in our example, a test case contains 3 phases. A phase is declared by the following:

 Label Occurrence
 SETUP :
 optional
 TEST :
 exactly one
 TEARDOWN :
 optional

Note that the space-columns ' :' are part of the label. A script must contain exactly one 'TEST :' section and may contain up to one 'SETUP :' and/or 'TEARDOWN :' section. The sections may be declared in any order. When a label is declared, no other element is allowed on the same line.

A section begins with a label and ends when another label begins or when the end of file is reached. Instructions must be placed within the boundaries of a section, and any instructions out of a section (mainly when placed before the first label) will cause an error and stop the processing.

Example : correctly structured test

SETUP :
//a comment
an instruction
another instruction

TEST :
some instructions
lots of instructions...

TEARDOWN :
more instructions
and a last instruction

Example : minimal test

TEST :
instruction
instruction
instruction...


Ecosystems Setup & Teardown scripts

As said before (See Squash-TA ecosystem), an ecosystem is a suite of test cases which have in common a setup phase and a teardown phase. An ecosystem may - but is not required to- define up to one setup script and one teardown script. They obey to the same rules than regular test scripts, except two points:
  • They don't care about phases : A setup or teardown script only contains instructions, no phase should be defined.
  • Regular resource names have a special context: the ecosystem context, which is common to BOTH setup and teardown ecosystem script and which is INDEPENDANT (in term of resources) of the test cases included in the ecosystem.
Note that unlike other tests (that may be named freely), setup and teardown scripts MUST be named respectively 'setup.ta' and 'teardown.ta'

Example : valid setup/teardown script

//that's right, no phase needs to be defined
//instructions are directly written as follow :

 

instruction
instruction
instruction...

An example of project containing ecosystems setup and teardown scripts :