Post-Function

The Post-function is run after each test function in the list no matter how the function completes or is terminated. The selected function must be a GLOBAL function (see Function Scopes), with two input arguments and no outputs.

The post-function is considered to be part of the test function that it runs after, so if it fails prematurely, e.g. calls EXIT or causes a runtime error, then it will as if the test function itself did so. This means that if the test function succeeds, but the post-function does not complete successfully, the result passed back to the caller (e.g. in the XJRunner Integration) will be 1 to indicate failure.

The CURRENT_TEST_FUNCTION and CURRENT_TEST_GROUP read-only built-ins are available to post-functions and may be useful in writing custom log files out. They contain the name and group of the test function that was previously run, not the name of the post-function.

Syntax

PostFunction( INT stopMode, INT result )()

Parameters

stopMode

Indicates how the test function terminated. The available values are as follows and are also defined as constants in the default Globals.xje file that is added to new projects by XJDeveloper.

Value Standard Globals.xje constant Meaning
0x0 FUNCTIONTERMINATION_RETURNED The test function completed normally (although the test may have failed)
0x1 FUNCTIONTERMINATION_BROKEN_CHAIN The test function stopped prematurely because of a broken chain
0x2 FUNCTIONTERMINATION_XJEASE_RUNTIME_ERROR The test function stopped prematurely because of an XJEase runtime error
0x9 FUNCTIONTERMINATION_OTHER_RUNTIME_ERROR The test function stopped prematurely because of some other runtime error
0x10 FUNCTIONTERMINATION_EXIT The test function stopped via the EXIT statement
0x11 FUNCTIONTERMINATION_ABORTED The user stopped execution (typically via the stop button in XJRunner)

(Note that the values 0x3 to 0x8 are reserved for future use, so it is best practise for any test function to handle them in the same manner it handles the 0x9 case)

result

Indicates the return value from the test. If the test did not complete, i.e. stopMode is not 0, then result is always 1.