To debug the test case, you must set a breakpoint, then use the Debug option within the
Micro Focus Unit Testing view.
-
Just as you would when debugging any other program, you need to set a breakpoint beforehand; if
DistanceTest.cbl is not already displayed in the editor, open it from COBOL Explorer.
The test program is displayed in the editor.
-
Set a breakpoint by double-clicking on the marker bar to the left of the line that starts:
string "Incorrect distance in kilometers returned...
-
In the
Micro Focus Unit Testing view, right-click
MFUT_TESTAIRCODE, then select
Debug.
-
If you are prompted to launch the Debug perspective, click
Switch.
The debug engine starts, and test execution stops at the breakpoint.
-
Hover over the
distance-km variable to see the distance between the two airports (Heathrow and Seattle).
The distance has been calculated as 7,703 (which happens to be the correct distance), and so the code is executing as it should.
It is also asserting a failure correctly, but that is because the wrong value (4,787) was being tested for, as you can see
from the following line:
if function numval(distance-km) not equal 4787...
-
Press
Ctrl+F2 to stop debugging.
Now that you know why the test failed, you can fix the code to test for the correct values.