Expectation and return code handling in automated test scenarios by Ralf THELEN Motivation You have been already in a situation where you wanted to use an output from a previous command to define the expected behavior of another command of the same scenario ? Probably what you did: you programmed a solution for this. The following shows a general solution without programming. The Idea of this solution Assuming there is an execution environment that supports the execution of a command, we did the following: 1. We extended the command input by an expectation expression, based on any previous command output or any previous return- or expected return codes, as well as literal expressions going to be used to evaluate the current command output. 2. We enhanced our automation layer to identify and evaluate the expectation expression and save return code, expected return code and command output for all commands.
Automated method determining if a computer command behaves as expected
Details of our solution:
Expectation Input of command n: a sequence of terms connected by standard logical operators (AND, OR) and logical NOT.
RC[i,
j] is the return code of the j-th instance of command i (assuming a scenario
is a sequence of n commands). Instances of the same command can be started to different point in times.
ERC[i,
j
] but the expected (evaluated) return code (i<n). Expression as a sequence of regular expressions. These are used to check if these are met by the output of command n.
OUT[i,
j,expression as a sequence of regular expressions.
Sequence of terms that are evaluated based on the output of command i (i<n,
-th
instance).
A program returning a bool value can be also a term of the expression with following syntax: REXX(name,parmstring) because in our environment we use the programming language z/OS REXX.
ERC calculation for command n:
The Expectation Input is evaluated by substituting the actual for RC[i,
ERC[i,
regular expression if the command output fulfills the expression. Then all terms result in a bool value and the result of TRUE or FALSE can be easily determined. Same is done for the previous command output if
OUT[i,
j,expression] is part of the expression, because output i has been stored
when command i was executed. A algorithm like specification is the following:
Evaluation of expectation expression for command k
Loop over all terms (specified in brackets, single quoted strings or ERC and OUT constructs)
Single quoted string(may contain * operators): check if it is contained in output (where * means any character sequence)
ERC(n): is the expected return code of n-the command already executed
OUT(i,
j,expectation expression) is the result of the expectation expression
evaluated for the command output for predecessor command i, instance j. REXX(name,parmstring) is the return value (bool) of the function 'name', which is called by the interpreter.
Compare result to the right sight of the term using the operator of the term (for each term a true or false is determined)
Replace the term by its result and continue looping until last term has been evaluated
Loop over all TRUE and FALSE constructs and evaluate the bool result by evaluating the logical expression. When the Expectation input (expression) is true the ERC will be set to TRUE otherwise to FALSE.
Some more details of determining the ERC (mention RC is the system command return code (usually 0 is OK and not 0 is ERROR):
RC = 0 (means OK, from a computer execution point of view) and logical expression is true, then ERC=TRUE
1
] same as RC[i,
j
j
j
] and
j] (stored after execution of command i) and verifying each term of the
RC = 0 (means OK, from a computer execution point of view) and logical expression is false, then ERC=FALSE
RC = 0 (means OK) and there is no further logical expression, then ERC=TRUE RC !=0 (means was not O...