Modify data to test different paths in the ZUnit test case of TOURFILE.cbl
In the test case editor, you can modify the data to test different code paths. This procedure also includes the procedure of finding errors in the application and fixing them using the ZUnit test case.
Before you begin
About this task
NUMBER-ENTRIESis 10 or above. Here we modify this value to test different code paths.
- Add TEST2 - discount case.
- Right-click TEST1 in the Tests pane, and
click Duplicate Test. You can also do this by using the test case editor
toolbar buttons. A TEST2 is duplicated from TEST1. You can double-click TEST2 and change its description to Discount in the Edit Test window to make it clearer.
- In the test case editor, find the TOURDATA - Input
file/Record:Record1/DATA-REC/I-NUMBER-ENTRIES item, and change its value from 2 to 10.
Find TOURMST - Output file/Record:Record1/TOUR-REC/O-NUMBER-ENTRIES and
change its value from 6 to 14. Find O-TOTAL-EXPENSE and change its value from
7800 to 16900. Each cell is now in the Result Details mode. You can find more details about this option in Setting the format for test results.
- Right-click TEST1 in the Tests pane, and click Duplicate Test. You can also do this by using the test case editor toolbar buttons.
Generate the test case program.
The ZUnit test runner starts. TEST2 fails in O-TOTAL-EXPENSE of TOUR-REC. You can see that the discount is not working.
The test case editor prompts you to save your changes.
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.
- Check the Generate test case for main program check box. Select the Generate, build, and run test case radio button.
ZUnit generates the test case for the TOURFILE.cbl program. The Run As Test Case dialog opens.
Select the Overwrite member check box for both the runner configuration
file and the runner result file.
- Click OK.
- Click Locate Job or OK in the Job Submission dialog.
- Click Generate.
- To fix the error in the TOURFILE.cbl program:
Discount should occur when W-NUMBER-ENTRIES is 10 or more, not more than 10.
- Open the source file in an editor.
- Comment out line 161, and uncomment line 162.
- Save the file.
- Submit <HLQ>.CNTL(TOURBLD) for compiling and linking the
application. Check that the return code is
- Click Refresh from Source in the test case editor toolbar.ZUnit test case editor is reopened for the updated TOURFILE.cbl file.
- Generate, build, and run the test case again as described in step 2.