Download presentation
1
Programming Types of Testing
2
Lesson Objectives Review and understand the concept of testing and debugging a program. Review the concept of a dry run test. Understand the concept of a trace table. Perform try run tests using trace tables.
3
Test and debug the program
Testing is performed by a tester or end user to find bugs, faults or error in the program. The tester reports to the programmer or program development team.
4
Types of Testing There are two types of testing: A dry –run test
involves applying test data to the program manually and tracing the logic or reasoning of the program using test data that will test each section of the program. This can even be done before the algorithm is translated into the programming language.
5
Types of testing Computer testing Compile the program.
A computer can only execute a program written in machine language. Before the computer can run the Pascal program, the latter must be converted to machine language. The source code must be converted into machine language. The program which does this is a compiler. The compiler will check for errors in the program. e.g syntax errors
6
Types of testing What are some types of syntax errors in Lazarus?
Omitting ; , ‘ () i.e. any violation of syntax rules
7
Types of testing Run the program.
The user requests the computer to execute the program and the user supplies data to the program for which he or she knows the answer. Such data is called test data. If the program does not give the correct answers the user knows that the program has at least one logic error. If the program contains logic errors we must debug the program; find and correct those errors.
8
Types of testing Debugging is the process of fixing the errors found by the testers. NB Debugging is done by the programmer to fix the errors during the debugging phase.
9
Question Distinguish between testing and debugging. (2mks)
10
Answer Testing is performed by a tester or end user to find bugs, faults or error in the program. The tester reports to the programmer or program development team. However, Debugging is the process of fixing the errors found by the testers. Debugging is done by the programmer to fix the errors during the debugging phase.
11
Types of testing What type(s) of testing have we been doing so far?
12
Dry Run Testing Dry-running or desk checking or tracing involves executing the program manually by using input values for variables and recording what takes place after each instruction is executed. Tracing is a technique that allows the user to detect any logic errors in the program or algorithm.
13
Trace Tables A trace table is a table that is completed by tracing the instruction of the algorithm with given data to arrive at solutions. In designing the table, draw a column for each variable used in the algorithm and draw enough rows to form the cells to store the values. There should also be a heading ‘Output’ to record what is printed.
14
Trace Tables Choose simple input test data which is valid. Two or three sets of data is valid. Establish what the expected results should be for each teat case. This is do a manual solution beforehand. Create a trace table of all the variables in the algorithm. Walk the first test case through the algorithm, keeping a step by step record of the contents of each variable in the table as the data passes through the logic until the algorithm reaches its logical end. Check that the expected result established in step two matches the actual result developed in step 4 Repeat the process using a different set of data.
15
Example Super six is the name of the junior cricket team. The coach of super six has hired you to design a program to provide him with statistics after each match. Design an algorithm that reads a list consisting of the number of runs scored by each batsman in the team. There are six batsmen in the team. Compute and print the average number of runs scored by the team. Solution
16
Computer Testing Computer testing
involves running the program using test data to discover any errors in the program.
17
Computer Testing Computer testing involves the following steps:
Compile the program. A computer can only execute a program written in machine language. Before the computer can run the Pascal program, the latter must be converted to machine language. The source code must be converted into machine language. The program which does this is a compiler. The compiler will check for errors in the program .e.g. syntax errors
18
Computer Testing Run the program.
The user requests the computer to execute the program and the user supplies data to the program for which he or she knows the answer. Such data is called test data. f the program does not give the correct answers the user knows that the program has at least one logic error. If the program contains logic errors we must debug the program; find and correct those errors.
19
Computer Testing The first step in computer testing is translating the high level program into machine code. The program written in the specific programming language is called the source code. The source code is translated into object code by the compiler. Programmers write programs in a form called source code. The source code consists of instructions in a particular language, like C or FORTRAN. Computers, however, can only execute instructions written in a low-level language called machine language.
20
Computer Testing To get from source code to machine language, the programs must be transformed by a compiler. The compiler produces an intermediary form called object code. Object code is often the same as or similar to a computer's machine language. The final step in producing an executable program is to transform the object code into machine language, if it is not already in this form. This can be done by a number of different types of programs, called assemblers, linkers, and loaders.
21
Computer Testing Converting a program to machine language is performed by a translator program. These are programs that translate a specific program from a high level language to machine language that the computer can understand. Interpreters, compilers and assemblers are all translators.
22
Interpreter An interpreter translates the source program line by line and if an error is detected then translation is aborted. If no errors are detected the interpreter instructs the control unit to execute the translated instruction. This cycle is repeated for each instruction. Therefore the interpreter translates one instruction at a time while the program is being executed. Translated codes are not saved; therefore each time the program is executed, translation is necessary.
23
Interpreter Advantages
It translates one instruction at a time; therefore it uses a minimum amount of memory. It is also helpful in the debugging process because the interpreter can relate error messages to the instruction being executed Disadvantage Each time the program is executed time is spent interpreting, hence a slower execution time.
24
Compiler A compiler translates all program instructions at one time and produces machine language which can be executed. Error checks are performed and an error summary is used. This is not done at run time. The translated codes are known as object codes and are saved as a file on a disk. The object code has an EXE file extension. It is then loaded or linked and executed. The object code is executed each time the program is run but the source code needs to be compiled only once.
25
Compiler Advantages EXE files execute faster than source codes. The object codes are saved and can be run at any time. Object codes are harder for a user to change than source codes The compiler checks the source code for syntax errors during compilation Disadvantages As the entire program is translated it uses much more of the computer’s memory.
26
Assembler The assembler translates mnemonic type instruction to machine code. It translates low-level languages to machine language. The assembler program takes each program statement in the source program and generates a corresponding bit stream or pattern (a series of 0's and 1's).
27
Run the Program The second step in computer testing is to run the program. The user requests the computer to execute the program. The two terms commonly used with program execution are linking and loading.
28
Linking A compiled object program is not executable by itself. It needs to be combined with other system modules to form an executable program. A linker also called a link editor and binder is a program that combines object modules to form an executable program. Linking combines various pieces of code and data together to form a single executable object than can be loaded in memory. Linking can be done at compile time at load time or at run time.
29
Loading Loading involves copying a program from the hard disk to main memory in order to put the program in a ready to run state.
30
Executing The Program Program execution is the process whereby the program is dispatched to the CPU. In many of the language compilers today, the process of compiling, linking and executing are transparent to the user. On some menu- driven systems the user selects compile from the menu and the program is compiled and linked from this single option. On other systems selecting ‘run’ results in the program being linked and executed.
31
Program Execution When the program is being executed or run the user supplies test data to discover any errors in the program. There are three types of errors: Syntax errors Logic errors Run-time errors
32
Syntax Errors Syntax errors are mistakes made by a non conformance to the grammatical rules of the programming language. For example if we forget to terminate an assignment statement with a semi- colon or if a reserved word was used incorrectly. Syntax errors stop the source code being converted to machine code. Syntax errors can be easily located and corrected as the compiler usually issues messages which identify the location of the errors.
33
Logic Error Logic errors occur due to out of sequence instructions, faulty comparisons and selections. For example in order to find the average of three numbers, the numbers must be entered and added before dividing by three. Dividing by three before entering the numbers would be a logic error. The program will usually compile. Compilation with logic errors does not generate any syntax errors or warning messages but when the program is run it produces the wrong results.
34
Runtime Error Run-time errors are errors that occur after the program has been tested and debugged. They occur during the execution and running of the program. They usually occur due to events such as division by zero or lack of memory for the computer to manipulate the data.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.