Record and import data into the ZUnit test case of CALL02.cbl

In the Test Case Editor, you can record data from a COBOL batch application, and import the data into a test case, and then generate, build, and run the test case of CALL02.cbl to see the test results for the imported data.

Recording and importing data

Before you begin

This procedure uses a sample program included with IBM® Developer for z/OS®. It also uses a z/OS project that was created by the sample setup procedure. Before using this procedure:
  1. Set up the sample files by using the instructions in Setup instructions for CALL02.cbl and Setup instructions for ZUnit test case.
  2. Create/modify a test case for the sample file and open the Test Case Editor by using the instructions in Create/modify a test case from CALL02.cbl.

Procedure

  1. On the main toolbar, click the Record DataRecord Data button.
    Record Data button
    The Record data for the test case window opens.
  2. Click Browse and select the <HLQ>.CNTL(CALL2RUN) that runs the CALL02.cbl application.
    Record data for the test case window
  3. Click Record Job.
  4. Click Locate Job or OK in the Job Submission dialog.
  5. Click Yes in the dialog that asks you whether you want to import the recorded data from the recorded data file.
    Import the recorded data from the recorded data file
    The recorded data is imported as TEST1. A message pop-up is displayed. In the Test Case Editor, you can see the imported data for PROCEDURE DIVISION. You can select SUB02A or SUB02B in the Layouts view to see their imported data.
    Test Case Editor view
    Test Case Editor view 2
  6. Right-click TEST1 in the Tests pane, and then click Duplicate Test.
    You get a TEST2 that is duplicated from TEST2.
  7. Select TEST2 in the Tests pane. Select the expected parameter value for ITEM1 in PROCEDURE DIVISION, right-click it and go to See Test Results Format > Result Details.
    Navigate to result details
  8. Edit the input parameter value from SUB02B to aabbcc in the data item ITEM1 of SUB02B, and edit the expected parameter value from 1111.00 to 3333.00 in SNUM10-02 of SUB02B.
    Edit input and expected parameter values
  9. Edit the input parameter value from 1111.00 to 3333.00 in the data item SNUM10-02 of SUB02A.
    Edit input parameter values
  10. Generate the test case program.
    1. Click Generate.
      Click the Generate button
      The Test Case Editor prompts you to save your changes.
    2. Click Yes.
      The Generate test case programs window opens. You can view the list of the test case and stub programs that ZUnit generates from the source program.
      Generate test case programs dialog
    3. Check the Generate test case for main program check box and select Generate test case.
    4. Click OK.
      ZUnit generates the test case for the CALL02.cbl program.
  11. Build and run the test case.
    1. In the z/OS Projects view, expand ZUnit Enterprise COBOL test data samples > call02 > <HLQ>.COBOL.SOURCE.COBOL(CALL02).cbl.
    2. Right-click on the CALL02.cbl source file, and select ZUnit (z/OS Automated Unit Testing Framework) > Build Test Case.
      ZUnit generates a JCL and submits a job to build the test case, and then prompts you to run the test case.
    3. Click Yes.
      The Run As Test Case dialog opens.
    4. Select the Overwrite member check box for both the runner configuration file and the runner result file.
      Settings for the Run Test Case dialog
    5. Click OK.
  12. Click Locate Job or OK in the Job Submission dialog.

Results

The ZUnit test runner starts and runs TEST1 and TEST2. When it completes, the ZUnit Runner Results view opens and shows that TEST1 passed the run and TEST2 failed the run.
Tests passed and failed

What to do next

Record and import data into the test case of SUB02A.cbl for sub program called by dynamic call