An Advanced Data-Driven Test Case Example

Note: The following example is run from the command line, but the source can also be used just as easily from the IDE.

This example consists of six files: three COBOL programs (MFUT_TESTFLYER_FILE.cbl, GetFlyerLevel.cbl, and GetFlyerLevel.cpy), one .csv file (FrequentFlyerFile.csv), and two other files that contain additional data under test (lorem.txt and gettysburg.txt). The source code/text for all of these files can be found in the appendix.

This example is similar to a conventional data-driven test, except that the .csv file under test references some additional data in two other files. As long as these files are loaded, using MFU_GET_FILE, prior to the tests being run, the Micro Focus Unit Testing Framework acts as if the data is part of the .csv file.

Note: All files created in the following example should be saved to and run from the same location.
  1. Create a COBOL program entitled MFUT_TESTFLYER_FILE.cbl, and use the appropriate source code in the appendix.
  2. Create another COBOL program entitled GetFlyerLevel.cbl, and use the appropriate source code in the appendix.
  3. Create a COBOL copy book entitled GetFlyerLevel.cpy, and use the appropriate source code in the appendix.
  4. Create a .csv file entitled FrequentFlyerFile.csv, and use the data in the appendix.
  5. Finally, create the two external sources (lorem.txt and gettysburg.txt), which are referenced in the .csv file, again using the text in the appendix.
  6. Compile the test:

    Windows:

    cbllink -D MFUT_TESTFLYER_FILE.cbl GetFlyerLevel.cbl

    UNIX:

    cob -zU -e "" MFUT_TESTFLYER_FILE.cbl GetFlyerLevel.cbl
  7. Run the test:

    Windows:

    mfurun -verbose:true MFUT_TESTFLYER_FILE.dll

    UNIX:

    cobmfurun[32|64] -verbose:true MFUT_TESTFLYER_FILE.so

    The output should be similar to that shown below, indicating that the test passes. If FrequentFlyerFile.csv had embedded the additional information referenced using the @lorem.txt and @gettysbury.txt syntax, the tests would have exceeded permitted size limits, and failed.

    Sample output from test run