Previous Topic Next topic Print topic


Unit Testing Code Snippets

Your IDE editor contains a number of snippets relating to the Micro Focus Unit Testing Framework; to insert one, type the shortcut in your editor and press Tab. The snippet is inserted into the code, and you are prompted to enter the test case name: either select the name from a list of level-78 constants that are defined in the program, or type a literal string.

Tip: Before creating a test case, create a level-78 constant for <test-case-name>; the value of this is offered from a list when inserting the snippet. Using the constant in the entry point names eradicates any spelling mistakes that may occur when creating the different elements for the test. Do not create constants that are prefixed with MFU; entry points prefixed MFU are reserved for the internal processing of the Micro Focus Unit Testing Framework and are deliberately filtered from the list offered.
shortcut snippet description
testcase
entry MFU-TC-PREFIX & <test-case-name>.
   *> Test code goes here.
   goback returning MFU-PASS-RETURN-CODE
   .
The main element of a test case. It's the section that contains the actual testing logic and test assertions.
testdata
entry MFU-TC-METADATA-SETUP-PREFIX & <test-case-name>.  *> the test case meta data
  move "ex. of a dynamic description" to mfu-md-testcase-description
  move 10000 to MFU-MD-TIMEOUT-IN-MS
  move "smoke,dynmeta" to MFU-MD-TRAITS
  set MFU-MD-SKIP-TESTCASE to false
  goback returning 0
  .
An optional element to a test case. It's the section that associates metadata with the test case. See Using Dynamic Metadata for more information on how to use the options shown here.
testup
entry MFU-TC-SETUP-PREFIX & <test-case-name>.  *> the test case setup
  goback returning 0
  .
An optional element to a test case. It's the section that sets up the environment before the testing logic is run.
testdown
entry MFU-TC-TEARDOWN-PREFIX & <test-case-name>. *> the test case tear-down
  goback returning 0
  .
An optional element to a test case. It's the section that tidies up after the testing logic has run.
Previous Topic Next topic Print topic