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.
About this task
This TOURFILE.cbl has an IF statement for discounting the total
expense when the value of NUMBER-ENTRIES
is 10 or above. Here we modify this value
to test different code paths.
Procedure
- 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.
-
Generate the test case program.
-
Click Generate.
The test case editor prompts you to save your changes.
-
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.
-
Check the Generate test case for main program check box. Select the
Generate, build, and run test case radio button.
-
Click OK.
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.
The ZUnit test runner starts.
TEST2 fails in
O-TOTAL-EXPENSE of TOUR-REC. You can see that the discount is not working.
- To fix the error in the TOURFILE.cbl program:
- Open the source file in an editor.
- Comment out line 161, and uncomment line 162.
- Save the file.
Discount should occur when W-NUMBER-ENTRIES is 10 or more, not more than
10.
- Submit <HLQ>.CNTL(TOURBLD) for compiling and linking the
application. Check that the return code is
0000
.
- 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.
Results
The ZUnit test runner starts and runs
TEST1 -
TEST2.
The error in
TOURFILE.cbl is fixed and the
TEST2 test case
has passed the run.