Record and import data into the AZUTC007.cbl test case

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 AZUTC007.cbl test case 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.
  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>.ZUNIT.JCL(CALL02) that runs the CALL02 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 TEST2. A message pop-up is displayed. In the Test Case Editor, you can see the imported data.
    Test Case Editor view
  6. Right-click TEST2 in the Tests pane, and then click Duplicate Test.
    You get a TEST3 that is duplicated from TEST2.
  7. Select TEST3 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.
  9. Edit the input parameter value from 1111.00 to 3333.00 in the data item SNUM10-02 of SUB02A, and the expected parameter value in the data items from 1111.00 to 3333.00 in SNUM10-02 of SUB02B.
    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 program.
  11. Build and run the test case program.
    1. In the z/OS Projects view, expand ZUnit Enterprise COBOL test data samples > sample7 > <HLQ>.ZUNIT.SOURCE.COBOL(CALL02).cbl.
    2. Right-click on the CALL02.cbl source file, and select z/OS Automated Unit Testing Framework (ZUnit) > 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 Test Case window opens.
    4. Select the Overwrite member check box for both the runner configuration file and the runner result file.
      Settings for the Run As 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, TEST2, and TEST3. When it completes, the ZUnit Runner Results view opens and shows that TEST1 and TEST2 passed the run and TEST3 failed the run.
Tests passed and failed