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.

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-JCL-FILE-NAME The file name of the JCL job card to be submitted. jcl-filename
MFU-MD-JCL-COND-TYPE The reason that the job ended.
MFU-MD-JCL-COND-CODE The resulting return code of the job.
MFU-MD-JCL-JOB-NBR The JCL job number.
MFU-MD-JCL-TESTCASE-PASSED The metadata that determines if the test case has passed or failed. Set to true to mark the test as passed, and false to mark it failed.

For example:

set MFU-MD-JCL-TESTCASE-PASSED to true
MFU-MD-JCL-COPY-DD

Generates output files on the running and results of a JCL job. If you want to make test assertions on the job, this metadata is mandatory. The default is true.

See JCL Test Case Example for an example of how to use the output in your tests.

es-show-dd
MFU-MD-JCL-FLUSH-JOB Determines if the completed job is flushed from the spool queue. Set to true to flush it on completion of the test, or false to retain the job within the queue. es-flush-job