ST Lab 01
ST Lab 01
Experiment 1
Introduction to Software Testing,
Identifying and Categorizing Software
bugs
TYPE: Accidental
pixels++;
Reason: Caused by a stray ";" on line 2. Accidental bugs are often caused by stray
characters, etc. While "minor" in their fix, they can be the devil to find!
Note: if used correctly, a "prettyprinter" or auto-indenter would help you spot this one.
EXAMPLE 2:
EXAMPLE 3:
TYPE:Dyslexic
return currmin;
Reason: Here, the ">" on line 5 should be "<". Even people who are not normally dyslexic
are subject to these types of errors.
EXAMPLE 4:
Reason: The cases were generated by copying case 1. Under case 3, the values were not
changed as appropriate for the case. Code reuse is good -- but this form of code copying has
its dangers!
EXAMPLE 5:
TYPE: Accidental
if (foo = 5)
foo == 7;
Reason: Two bugs in one. These are usually caused by accident rather than
misunderstanding. The "=" of line 1 should probably be "==" (this one will always evaluate
to true), while the "==" of line 2 should almost certainly be "=" (it has no effect). A
syntactic weakness in C/C++, neither of these statements is syntactically wrong. Many
compilers will warn you about both of these.
EXAMPLE 6:
int foo(int j)
{
for (i=0; i<j; i++)
do_nothing();
return j;
}
void ineedj(void)
{
cout << "j is " << j << "\n";
}
main()
{
int j;
j =foo(i);
ineedj();
}
Reason: This illustrates some fun with global/local variables. In function foo, j is local
and i is global. Since i is being used as a loop variable, this is almost certainly wrong.
Making j local here may or may not be logically correct, but it is certainly stylistically
incorrect since the semantic meaning of j is being used in two distinct ways (once as a
global, once as a local, which by definition must be inconsistent). In main, j is local. So,
when it gets set by the call to foo, the global value is not being set. So, ineedj is out of
luck -- the value is still undefined.
Note: If the variable is global, never use that name for anything else.
2) Communication Errors:
These errors occur in communication from software to end-user. Anything that the end user
needs to know in order to use the software should be made available on screen.
Few examples of communication errors are – No Help instructions/menu provided, features
that are part of the release but are not documented in the help menu, a button named ‘Save’
should not erase a file etc.
3) Missing command errors:
This happens to occur when an expected command is missing. See this screenshot:
This window allows the user to create a new project. However, there is no option for the
user to exit from this window without creating the project. Since ‘Cancel’ option/button is
not provided to the user, this is a missing command error.
When possible, further steps should be listed for the user to follow.
If the software has certain mandatory fields that need to be filled before they can save the
information on a form, the validation messages should be clear and indicative of the action
that is required by the user. Here are other examples:
6) Calculation Errors:
These errors occur due to any of the following reasons:
• Bad logic
• Incorrect formulae
• Data type mismatch
• Coding errors
• Function call issues , etc.
In 1999, NASA lost its Mars climate orbiter because one of the subcontractors NASA
employed had used English units instead of the intended metric system, which caused the
orbiter’s thrusters to work incorrectly. Due to this bug, the orbiter crashed almost
immediately when it arrived at Mars.
7) Control flow errors:
The control flow of a software describes what it will do next and on what condition.
For example, consider a system where user has to fill in a form and the options available to
user are: Save, Save and Close, and Cancel. If a user clicks on ‘Save and Close’ button, the
user information in the form should be saved and the form should close. If clicking on the
button does not close the form, then it is a control flow error.
3-Software Defect Taxonomies
In software test design we are primarily concerned with taxonomies of defects, ordered lists
of common defects we expect to encounter in our testing.
Beizer's Taxonomy
One of the first defect taxonomies was defined by Boris Beizer in Software Testing
Techniques. It defines a four-level classification of software defects. The top two levels are
shown here.
1xxx Requirements
11xx Requirements incorrect
12xx Requirements logic
13xx Requirements,
completeness
14xx Verifiability
15xx Presentation, documentation
16xx Requirements changes
4xxx Data
41xx Data definition and structure
42xx Data access and handling
Programmers (and testers) sometimes have optimistic views about bugs. Here are some of
them:
• Bug locality hypothesis
–Belief: Bug discovered in module A probably only affects A because my program
is well-structured
–Reality: Subtle bugs show up far away (both in space and time) from the cause
• Good Language Constructs
–Belief: Good programming languages and practices, such as strong typing or
structured coding, prevent most bugs
–Reality: True to an extent, but no statistical evidence in big systems
• Code/Data separation
–Belief: Bugs tend to respect the separation between code and data
–Reality: Well, if you assume your computer will never execute your data as code
accidentally modify an instruction by incrementing its op code then pray when
executing your programs
• Corrections stay
–Belief: A corrected bug remains corrected
–Reality: First of all, how can you be sure that you have actually corrected a bug in
the first place?
Silver bullets
–Belief: X (a language, methodology, technique, etc) grants immunity against bugs
–Reality: In you trust X blindly, you’re in for a hard time
• Smartness suffices
–Belief: If you are smart you’ll catch most bugs
–Reality: Maybe true for fairly easy bugs. Subtle bugs also need methodology,
techniques and rigour
Lab Tasks
• Make a list of at least 5 examples of specific bugs
• In what software? What was the failure? What fault caused it?
– Use your own experience
– Order them from most to least important (critical, frequent)
• Try to group the bugs (yours and others) into categories
– Try to define broad categories (maybe aim for 8)
– (hint: think of the whole software engineering process)
– Tick the two categories that you think contain the most frequent bugs