You can learn about Introduction to Programming Using Python Programs with Outputs helped you to understand the language better.
Introduction to Python Programming – Testing A Program
Testing A Program
In order to completely test a program logic, the test data must test each logical path of the program. Hence, the selection of proper test data is very important in program testing. In general, the test data selected for testing a program should include:
a. Normal data, which will test the generally used program paths.
b. Unusual but valid data, which will test the pro-gram paths used to handle exceptions. Such data might be encountered occasionally while running the program.
c. Incorrect, incomplete, or inappropriate data, which will test the error-handling capabilities of the program. This is done in order to see how the program reacts in abnormal and unusual circumstances.
If a program runs successfully with the test data and produces correct results, it is normally released for use. However, even at this stage, errors may remain in the program. In the case of complex systems, there may be thousands of different possible paths through which the program is to be tested, and it may not be practical to trace through all these paths during testing.
Methods of Correcting Logical Errors
Some ways to locate and correct logical errors are briefly described below:
a. One approach is to study the source code producing the incorrect results and try to determine the cause of the problem.
b. Put several print or write statements in the program that indicate the values of intermediate computations. Once the errors have been found and corrected, such print or write statements are removed from the program.
c. Use tracing routines which are software tools provided to the programmer to help in debugging the program logic. Tracing routines or debug packages assist the programmer in following the logic by printing out intermediate calculated results and field values that are used in making logical decisions in the program. using these techniques, the programmer can follow the program execution step-by-step in order to determine where the logic has an error,
d. Look at a printout of the contents of memory. This printout is called a storage dump or memory dump. The memory dump lists the instructions and data held in the computer memory in their raw form, that is, their binary or equivalent hexadecimal or octal form. The programmer can then study this listing for possible clues to the cause of the programming error(s). Most programmers of high-level languages resort to the use of memory dumps only when all other methods of detecting the logical error fail.
Differences between Testing and Debugging
Testing and debugging are two separate tasks. The differences between these two processes are out- in making logical decisions in the program. lined in Table 1.1.
|1.||Testing is the process in which a program is validated.||Debugging is the process in which program errors are removed.|
|2.||Testing is complete when all desired verifications in terms of the specifications have been performed.||Debugging is a process that ends only temporarily, as subsequent execution of a program may uncover other errors, thereby restarting the debugging process.|
|3.||Testing can and should be planned. It is a definable task in which how and what to test can be specified. It can be scheduled to take place at a specific time in the development cycle.||Debugging is a reactive procedure which stems from testing. It cannot be planned ahead of time. The best that can be done is to establish guidelines of how to debug and develop a list of “what to look for.”‘|
|4.||Testing can begin in the early stages of the development effort. Of course, the tests themselves must be run near the end of the project, but the decisions of what to test, how to test, with what kind of data it is to be tested and should be completed before the coding is started.||Debugging, on the other hand, cannot begin until the end of the development cycle because it requires an executable program.|