Previous Topic Next topic Print topic


Debugging the Failed Test

To debug the test case, you must set a breakpoint, then use the Debug option within the Micro Focus Unit Testing view.
  1. 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.

  2. Set a breakpoint by double-clicking on the marker bar to the left of the line that starts:
    string "Incorrect distance in kilometers returned...
  3. In the Micro Focus Unit Testing view, right-click MFUT_DISTANCETEST, then select Debug.
  4. If you are prompted to launch the Debug perspective, click Yes.

    The debug engine starts, and test execution stops at the breakpoint.

  5. 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...
  6. 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.
Previous Topic Next topic Print topic