Testing
Testing is the way to find the errors in a program. Purpose of testing is to improve the software and to make it error free.
Debugging
Testing
Testing is the way to find the errors in a program. Purpose of testing is to improve the software and to make it error free.
Debugging
Debugging is one kind of
problem solving method which is useful to locate the correct error in the
program.
Types of Errors
Errors are very common when
writing computer programs. If we want to execute a source code file, different
stages like compilation linking and execution are required.
A user can expect the errors indicated
by the different modules running on the computer system, namely compiler linker
and loader.
There are the following types
of Programming errors:
- · Run Time Errors
- · Compile Errors: syntax and semantic errors
- · Logical Errors
Run Time
Errors
It is an error that occurs
during the execution of program.
In programming, errors are also
known as bugs.
Run time error indicate bugs in
the program or problems like insufficient memory or a segmentation fault caused
by trying to access a memory location to that is not allowed to access.
Run time error may crash
your program when you run it.
Run time errors usually
caused when a program perform operation like dividing a number by zero or find
the square root of negative integer or to fine the algorithm of negative number
or when there is not enough memory space.
Occurrence of these errors may
stop program execution.
Run time errors are usually
more difficult to find and fix than syntax errors.
Compile
Errors
Compile errors are those errors that occur at the time of compilation of the program. C compile errors may be further classified as: (I) Syntax error (II) Semantic error
(I) Syntax Errors.
Whether it is a natural
language or programming language, there are a set of rules in sentence -
building which govern the word order and this is called syntax.
In the English language a
sentence is built as per the rule of subject –verb- object agreement and violation
of this rule is regarded as a syntax error.
In C programming there are
a set of rules for writing program statements, the violation which constitutes
a syntax error.
Syntax error occurs when
the code is written in a manner not permitted by the rules of the program
language.
These errors are easily
traceable at the compilation time. Error messages and flagged lines are
displayed by the compiler.
In Visual studio by
Microsoft which supports C programming language, the error messages are made to
appear in the Output window.
These messages will tell
the location of a syntax error (line number and file) and a short description
of what the compiler thinks the error is. Some examples of syntax error are
given below:-
·
Missing semicolon ( ; ) at the
end of statement.
·
Missing any of delimiters
i.e { or }
·
Incorrect spelling of any
keyword.
·
Using variable without
declaration etc.
Syntax errors are the easiest to find and fix.
Over the years, compiler developers have worked
hard to make compilers smarter so that they can catch errors at compile time
that might otherwise turn out to be runtime errors.
(II) Semantic Errors.
The error that occurs
in the logic of a program is called semantic error.
It is always a
violation of the rules of meaning of a natural language or programming language.
When it occurs it
leads to incorrect output. It can even cause the program to hang or crash.
Compared with the
syntax error, it is a more difficult type of error as it cannot be easily
traced.
A semantic error occurs when the syntax of
your code is correct, but the (semantics) meanings are not what were intended.
Since the syntax rules
are obeyed, semantic errors are not recognized either by the compiler or
interpreter, because Compilers and interpreters concern themselves only with the
structure of language, not the meaning.
Due to this error, the
program may terminate suddenly or enter into an indefinite loop.
The error diagnostic
is produced by some run time systems. When such errors are fixed and corrected
the correct results are produced.
Logical Errors
Logic errors are the errors in the output of the program and they occur when a programmer implements the algorithm for solving a problem incorrectly.
A statement with logical error may produce unexpected and wrong results in the program.
Common examples are:
· Multiplying when you should be dividing
· Adding when you should be subtracting
· Opening and using data from the wrong file
Debugging
Of Programs
Debugging means removing bugs
from a program.
A bug is an unexpected and undesirable behavior by a program.
In computers, debugging is the process of locating and fixing bugs (errors) in
computer program code. The first step in removing the bug is identifying it.
Some bugs are quite obvious, as
when the program crashes unexpectedly. Others are obscure, as when the program
produces output which is incorrect.
Debugging must necessarily
answer two questions:
"What did the program
do?" and "What did we expect the program to do?"
The aim is to determine the
behavior of the program to let us know why it is not running the desirable way
we wanted it to run.
To debug a program is to
isolate the source of the problem, and then fix it. Debugging is a necessary
process in any new software or hardware development process, whether it is a
commercial product or a personal application program. Because most computer
programs and many programmed hardware devices contain thousands of lines of
code, almost any new product is likely to contain a few bugs. Invariably, the
bugs in the functions that get most use are found and fixed first.
The first step in fixing a bug
is to replicate it. This means recreating the undesirable behavior under
controlled conditions. The aim is to find by way of precise steps, the presence
of the bug.
In many cases this method is
straightforward. We can run the program with an input to see if the bug occurs.
Debugging tools (called debuggers)
help identify coding errors at various development stages. Some programming
language packages include a facility for checking the code for errors as it is
being written.
Compilers can be configured to
produce debug information at compile time, so that this information can be used
by the debugger program to view source code as we debug. Debugging is often
supported by a software tool in most of the IDE. Using such tools the user can
investigate the program behavior by introducing break points in the program. At
every break points the system.
Suspends execution so as to
facilitate the checking of intermediate results. One can even modify the values
of the program variables when the break point is reached. After debugging this
break point are to be removed so that the program can be subjected to normal
compilation and later execution.
Testing
Stage
This is an important stage, as
the acceptance of the program depends on testing and subsequent validation. As
the program is being coded, and completed it must be tested out to see if it is
running properly and it produces the required output with appropriate input data.
The input and output must
conform to the requirements that is, to make sure that the algorithm of the
program does what it should be intended to do, whether the program fits as
expected into the intended application environment.
There are different methods of
testing like black box, white box and Grey Box method of testing.
The technique of testing
without having any knowledge of the interior workings of the application is Black box testing.
White
box
testing is the detailed investigation of internal logic and structure of the
code.
White box testing is also
called glass testing or open box testing. In order to perform white box testing
on an application, the tester needs to possess knowledge of the internal
working of the code.
Grey
box
testing is a technique to test the application with limited knowledge of the
internal workings of an application. The tester needs to have a look inside the
source code and find out which unit/chunk of the code is behaving
inappropriately.
The program will be tested for
all possible input, without which it is not possible to declare that it works
satisfactorily. Once testing leads to satisfactory results, the program is
considered to be working correctly and is accepted.
0 comments:
Post a Comment