The data file is added to the unit test project.
The data file is renamed.
This ensures that if the file is edited, the most up-to-date version is always available in the output directory, to be used at run time.
The configuration file is added to the project.
The Application Settings dialog box appears.
01 errormessage pic x(200).
move 4 to lnk-function call "AIRCODE" using by value lnk-function by value lnk-airport1 by value lnk-airport2 by value lnk-prefix-text by reference lnk-rec by reference lnk-distance-result by reference lnk-matched-codes-array by reference lnk-file-status end-call *> did we open the file? if lnk-file-status not equal "00" call MFU-ASSERT-FAIL-Z using TEST-TESTAIRCODE & " failed to open file" & x"0" exhibit named lnk-file-status end-if
This code attempts to open the data file, and if it cannot open the file, fails the test and outputs the failed file status.
move 2 to lnk-function move "LHR" to lnk-airport1 *> London Heathrow move "SEA" to lnk-airport2 *> Seattle
*> Assertions to check that the correct distance is returned if function numval(distance-miles) not equal 4787 string "Incorrect distance in miles returned - " distance-miles delimited by size x"0" delimited by size into errormessage end-string call MFU-ASSERT-FAIL-Z using errormessage end-if if function numval(distance-km) not equal 4787 string "Incorrect distance in kilometers returned - " distance-km delimited by size x"0" delimited by size into errormessage end-string call MFU-ASSERT-FAIL-Z using errormessage end-if
These are the assertions that check that the correct values are calculated for the distance (in miles and km) between the two airports, and if the calculation is incorrect, the test fails.
exhibit named distance-miles exhibit named distance-km
This code outputs the results of the calculations to the Output pane.
An MFU-TC-TEARDOWN-PREFIX & TEST-TESTAIRCODE entry point is added to the program.
move 5 to lnk-function call "AIRCODE" using by value lnk-function by value lnk-airport1 by value lnk-airport2 by value lnk-prefix-text by reference lnk-rec by reference lnk-distance-result by reference lnk-matched-codes-array by reference lnk-file-status end-call *> did we close the file? if lnk-file-status not equal "00" call MFU-ASSERT-FAIL-Z using TEST-TESTAIRCODE & " failed to close file" & x"0" exhibit named lnk-file-status end-if
This closes the data file after the test case has run.
The test case fails, and outputs the following to the Test Results pane:
The next task is to debug the test case to find out why it failed.