Use test results to correct an error in the TOURFILE.cbl program

The TOURFILE.cbl program contains an error that can be detected by a third test entry. Use the Test Case Editor, to add a third test entry to detect this error, and then generate, build, and run the TTOURFIL.cbl test case. Use the test results to find and correct the error.

Correcting an error

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 by using the instructions in Create/modify a test case from TOURFILE.cbl.
  3. Add data, and generate, build, and run the test case by using the instructions in Add data to the AZUTC004.cbl test case.
  4. Import data into the test case, and generate, build, and run the test case by using the instructions in Import data into the AZUTC004.cbl test case.

Procedure

  1. In the Test Case Editor, click the Add Test toolbar button.
    TEST3: Input and TEST3: Expected columns are added to the editor.
    Test Case Editor with TEST3
  2. In the CHECK_CODE field of the TEST3: Input column, type Y.
  3. Copy the values for the TOURDATA parameters from Record1, Record2, and Record3 of the ENTRY1 test entry to Record1, Record2, and Record3 of the EXTRY3 test entry.
  4. In the I_TOUR_CODE field of Record1 of the TEST3: Input column, type 111.
    Test Case Editor with data in TEST3
  5. In the O_TOUR_NAME field of the Record1 of the TOURMST file of the TEST3: Expected column, type CODE-INVALID.
    Test Case Editor with TOURMST file in TEST3
  6. Generate, build, and run the test case with test data in TEST3:
    1. In Test Case Editor, click the Generate.
      The Test Case Editor prompts you to save the changes.
    2. Click Yes.
      The Generate test case programs window opens.
    3. Select Generate, build and run the test case, and click OK.
      ZUnit generates the test case and build them. The Run As Test Case window opens.
    4. Select the Overwrite member check box for both the runner configuration file and the runner result file.
    5. Click OK.
      The ZUnit test runner starts and runs the ENTRY1, AZUE0000, and TEST3 tests. After the test completes, the ZUnit Runner Results view opens and shows that the ENTRY1 and AZUE0000 tests passed, but the TEST3 test failed.
      TTOURFIL Test Runner Results
  7. To fix the error in the TOURFILE.cbl program, open the source file in an editor, comment out line 107, and uncomment line 108.
  8. Close and save the TOURFILE.cbl file.
  9. Compile and link <HLQ>.ZUNIT.COBOL(TOURFILE) as <HLQ>.ZUNIT.COBOL.LOAD(TOURFILE). Specify typical compiler options for a batch program.
  10. Close the Test Runner Results view and the Test Case Editor.
  11. In the z/OS Projects view, right-click the TOURFILE.cbl source file and click z/OS Automated Unit Testing Framework (ZUnit) > Create/modify Test Case.
  12. In the Create/modify a test case window, click Edit Test Entry Data.
    A message window opens and indicates that the test data layout is updated because the source file is changed.
    Generating test data layout window
  13. Click OK.
  14. Generate, build, and run the test case.
    The Test Runner Results view opens and shows that all three tests pass.