Examples of using Metadata

The following excerpts show examples of how you can use dynamic metadata in your test code.

Configuring command line arguments

The following excerpt demonstrates how you can apply a conditional command line argument to your test run, based on the type of compiled file used to create the test fixture file or executable. By moving the appropriate -report value to the MFU-GLOBAL-COMMANDLINE-ARG variable, the appropriate report will be generated.

...
entry MFU-GLOBAL-COMMANDLINE-PREFIX & "CMDOPT".

       $if ilgen set
         $if nojvmgen set
            move "-verbose -high-res-timer:true -report:nunit" to MFU-GLOBAL-COMMANDLINE-ARG
        $else
           move "-verbose -high-res-timer:true -report:junit" to MFU-GLOBAL-COMMANDLINE-ARG
        $end
       $else
           move "-verbose -high-res-timer:true -report:markdown" to MFU-GLOBAL-COMMANDLINE-ARG
       $end
        goback
...

Configuring global metadata

The following excerpt demonstrates metadata being applied to all test cases in the test run. In this example, all test cases in the file TestRunName will be assigned the trait of 'fulltest'.

...
entry MFU-GLOBAL-METADATA-PREFIX & "TestRunName".
	move "fulltest" to MFU-MD-TRAITS
	goback
...

Configuring specific test case metadata

The following excerpt demonstrates metadata that can be applied to an individual test case. In this example, a number of details are added to the test case 'TestCase1'.

...
entry MFU-TC-METADATA-SETUP-PREFIX & "TestCase1".
           move "This is an example of a dynamic description" to MFU-MD-TESTCASE-DESCRIPTION
           move 3000 to MFU-MD-TIMEOUT-IN-MS
           move "smoke" to MFU-MD-TRAITS
           set MFU-MD-SKIP-TESTCASE to false
           move MFU-MD-TESTCASE-PRIORITY-LOW to MFU-MD-TESTCASE-PRIORITY
           goback.
...

Configuring a JCL unit test

The following excerpt demonstrates some of the environmental setup required to run a JCL unit test. The MFU-MD-JCL-FILE-NAME metadata specifies the JCL job card to be submitted, and the MFU-MD-JCL-COPY-DD metadata ensures that any JCL output from the job is saved to a text file, which can then be queried when making your test assertions. The MFU-MD-JCL-FLUSH-JOB metadata removes the job created by the test from your JES queues; this metadata is not mandatory. The other elements required to running a JCL test (the enterprise server region and the catalog) are specified on the command line.

...
entry "MFUM_TXTDIFF1".
   move "txtdiff.jcl" to MFU-MD-JCL-FILE-NAME
   move "COBOL/JCL Unit Test" to MFU-MD-TESTCASE-DESCRIPTION
   set MFU-MD-JCL-COPY-DD to true  
   set MFU-MD-JCL-FLUSH-JOB to true
   goback.
... 

Configuring a data source for a data-driven test

The following excerpt demonstrates how to configure a data source for your data-driven tests. In this example, the TestCSV test case will use the FrequentFlyer.csv data source. The separator used within the file is ';' (and not the default, comma). Each test case is run a number of times: once for each selected line within the file. In this instance, any line that has does not have a value of Platinum in the InitialStatus column is omitted.

...
entry MFU-TC-METADATA-SETUP-PREFIX & "TestCSV".
           move "This is an example of a data driven test" to MFU-MD-TESTCASE-DESCRIPTION
           move "csv:FrequentFlyer.csv" to MFU-MD-TESTDATA
           move "InitialStatus != Platinum" to MFU-MD-DD-CSV-FILT-COND
	          move ";" to MFU-MD-DD-DSV
           goback.
...