Using Dynamic Metadata

You can add metadata about a test case in your source code.

The Micro Focus Unit Testing Framework contains a number of COBOL fields within the mfunit.cpy copybook that enable you to add metadata to your test cases.

For metadata relating to a particular test case, set the COBOL fields within the MFU-TC-METADATA-SETUP-PREFIX & test-case-name entry point. (If you are unable to use level 78 constants, use the "MFUM_test-case-name" entry point name instead.) This entry point is called during the preparation stage of the test case.

For metadata relating to all test cases in your test suite, set the COBOL fields within the MFU-GLOBAL-METADATA-PREFIX & program-name entry point. (If you are unable to use level 78 constants, use the "MFUGM_program-name" entry point name instead.) This entry point is called before any of the test cases.

If you generate a test fixture file (.mfu file) from the test suite, you can see the metadata within the test cases, and in the [global] section.

Use the following COBOL fields to populate your test case-specific and global metadata entry points:

COBOL field Description Tag in the test fixture .mfu file
MFU-MD-TESTCASE-DESCRIPTION Test case description description
MFU-MD-TIMEOUT-IN-MS
The time limit (in ms) in which the test case should run. A non-zero return code is returned if the timeout is reached. The timeout must be set to at least 3 seconds.
Note: If a test uses a timeout, it must be run on UNIX platforms using one of the threaded test runners (cobmfurun32_t or cobmfurun64_t).
timeout
MFU-MD-TRAITS Test case traits. You can run test cases based on the trait; any tests that are not assigned the specified trait are skipped during the test run.
Tip: You can add more than one trait, delimited by a comma, if required.
traits
MFU-MD-SKIP-TESTCASE Skip test case skipped
MFU-MD-TESTCASE-PRIORITY Give priority to a test case. Permissible values are:
  • MFU-MD-TESTCASE-PRIORITY-HIGH
  • MFU-MD-TESTCASE-PRIORITY-MEDIUM
  • MFU-MD-TESTCASE-PRIORITY-LOW
Note: Any test cases that do not have a priority specified are run after all prioritized test cases have run.
priority
MFU-GLOBAL-COMMANDLINE-ARG Applies test runner arguments to the test run. Use this field in the MFU-GLOBAL-COMMANDLINE-PREFIX entry point.
Note: The length of this field is limited to 128 characters.
various
MFU-MD-TESTDATA Applies to data-driven tests. This option enables you to specify a data source for your data-driven tests. (Currently, only data sources in comma separated values format are supported.)

For example:

move "csv:payroll.csv" to MFU-MD-TESTDATA

data-source
MFU-MD-DD-CSV-FILT-COND Applies to data-driven tests. This option enables you to filter the data from the data source that is used in your test case. Specify a condition to select or ignore rows of data in the source.

For example:

move "column_name condition data-value" to MFU-MD-DD-CSV-FILT-COND

where:

column_name
The name of a column header in your data source.
condition
Can be one of:
  • =
  • !=
  • contains
  • !contains
data-value
The value on which to base the filter.
ds-csv-filter-condition
MFU-MD-DD-DSV Applies to data-driven tests. This option enables you to specify the separator in the data file. (By default, the separator is a comma.)

For example, to use a semi colon:

move ";" to MFU-MD-DD-DSV

ds-csv-separator
MFU-MD-PP-CONTROLLER

Determines the entry point that will controls the flow of execution when a program is mocked using the MFUPP preprocessor.

MFU-MD-PP-REDIRECTOR Determines the name of the entry point that will serve as replacement code to an entry point or section in the source code under test .