A Simple Data-Driven Test 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 four files; the source code for those file can be found in the appendix. The test also uses an additional copy book, mfunit.cpy, which should automatically be utilized if your environment is configured correctly.

The test case is run a number of times (once for each line in the data file), where it compares the initial and final statuses of a fictitious frequent flyers program.

Compile the two program to .dll (Windows) or .so (UNIX) (see Compiling Tests), then run the resulting test suite (see Running Tests).

  1. Create a COBOL program entitled MFUT_TESTFLYER.cbl, and use the source code in the appendix.
  2. Create another COBOL program entitled GetFlyerLevel.cbl, and again use the appropriate source code in the appendix.
  3. Create a COBOL copy book entitled GetFlyerLevel.cpy (ensuring to save it to the same location as the two COBOL programs), and use the appropriate source code in the appendix.
  4. Finally, create a .CSV file entitled FrequentFlyer.csv, and use the data in the appendix. Again, ensure it is saved to the same location as the other files.
  5. Compile the test:

    Windows:

    cbllink -D MFUT_TESTFLYER.cbl GetFlyerLevel.cbl

    UNIX:

    cob -zU -e "" MFUT_TESTFLYER.cbl GetFlyerLevel.cbl
  6. Run the test:

    Windows:

    mfurun -verbose:true MFUT_TESTFLYER.dll

    UNIX:

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

    The output should be similar to that shown below, indicating that the test passes after running 6 times (once for each row in the data source).