The Micro Focus Unit Testing Framework supports data-driven tests when connecting to data sources in comma separated values (CSV) format.
You can incorporate a data source into your traditional unit tests by specifying a data source descriptor, MFU-MD-TESTDATA, in the metadata entry point; for example:
ENTRY "MFUM_MYTESTCASE". move "csv:MyCSVSource.csv" to MFU-MD-TESTDATA.
When the test case is executed, it runs once for each row of selected data within the data source. For this reason, there are two additional data-driven-specific test elements - a data-driven test setup and a data-driven test teardown. These are similar to conventional setup and teardown elements (which you can still use), but they are only run once per test run - conventional equivalents would run before/after test case execution of each selected row. These specific sections are useful for such things as connecting/disconnecting from the data source - something that may only need to run once per test run. See Elements of a Test Fixture for more information.
move "Surname = Jones" to MFU-MD-DD-CSV-FILT-CONDYou can also selectively run the test case against a single row within the source if you are using the -csv-line-filter option from the command line test runner syntax.
To use the data in your test cases, you define external COBOL items in the Working Storage that correspond to the column headers; for example, to define and use data in a column titled EarnedPoints, define the COBOL item as such:
01 mfu-dd-EarnedPoints is MFU-DD-VALUE external.
You can then use the item in your test code as you would any other data item.
There are restrictions on the size of data that can be tested; see Restrictions in the Micro Focus Unit Testing Framework. However, you can circumvent some of these limits by storing long/complex field data in an external file. To reference external data in your .csv files, use the @file-name notation in a cell, and then before the test is run, load the file into memory using the MFU_GET_FILE or MFUGETF library routines. During the test run, the test acts as if the cell contains the contents of the referenced external file.
Refer to the Data-Driven Test Case Examples section for working examples of data-driven tests.