Exception Environment (Error Recovery Block)

System Testing for C

A test script is composed of a hierarchy of scenarios. An exception environment can be defined at a given scenario level.

When an error occurs in a scenario all exception blocks at the same level or above are executed sequentially.

The syntax for exception environments can take two different forms, as follows:

  • A block: This begins with the keyword EXCEPTION and ends with the sequence END EXCEPTION. A termination block can contain any instruction.

  • A procedure call: This begins with the keyword EXCEPTION followed by the name of the procedure and, where appropriate, its arguments.

Example

In the following example, the highest level of the test script is made up of two scenarios called first and second. The exception environment that precedes them is executed once if scenario premier finished with an error, and once if scenario second finishes with an error.

HEADER "Validation", "01a", "01a"

PROC Unload_mem()

...

END PROC

EXCEPTION Unload_mem()

SCENARIO first

...

END SCENARIO

SCENARIO second

EXCEPTION

...

END EXCEPTION

SCENARIO level2_1

FAMILY nominal, structural

...

END SCENARIO

SCENARIO level2_2

FAMILY nominal, structural

...

END SCENARIO

END SCENARIO

Scenario second is made up of two sub-scenarios, level2_1 and level2_2. The second exception environment is executed after incorrect execution of scenarios level2_1 and level2_2. The highest-level exception environment is not re-executed if scenarios level2_1 and level2_2 finish with an error.

Only one exception environment can appear at a given scenario level.

An exception environment can appear among scenarios at the same level. It does not have to be placed before a set of scenarios at the same level.

In a test report, the execution of an exception environment is shown even if you decided not to trace the execution.

Related Topics

Error Handling | Environments