SOFTWARE QUALITY ASSURANCE &
TESTING
LECTURE # 11
SOFTWARE TEST DESIGN TECHNIQUES
Fault Handling Techniques
Fault Handling
Fault Tolerance
Fault Avoidance Fault Detection
Design Atomic Modular
Methodology Reviews Redundancy
Transactions
Configuration
Verification
Management
Testing Debugging
Unit Integration System Correctness Performance
Testing Testing Testing Debugging Debugging
nd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 3
Quality Assurance encompasses
Testing
Quality Assurance
Usability Testing
Scenario Prototype Product
Testing Testing Testing
Fault Avoidance Fault Tolerance
Atomic Modular
Configuration Transactions Redundancy
Verification
Management
Fault Detection
Reviews
Debugging
Walkthrough Inspection
Testing
Correctness Performance
Unit Integration System Debugging Debugging
nd Bruegge & Allen H. Dutoit
Testing Testing Testing
Object-Oriented Software Engineering: Using UML, Patterns, and Java 4
Preamble
Is ‘exhaustive’ testing possible?
Can we test everything?
In order to know what the system should do, we need to have
a source of information about the correct behavior of the
system - this is called an 'oracle' or a test oracle.
Test Design Techniques
There are many different types of software testing techniques,
each with its own strengths and weaknesses.
Each testing technique falls into one of a number of different
categories.
Broadly speaking there are two main categories, static and
dynamic.
Static Testing
Control Flow
The sequence in which operations are performed by a business
process, component or system.
Data Flow
A type of static analysis based on the lifecycle of variables e.g.,
creation, usage, modification or destruction.
Dynamic Testing
Dynamic techniques are subdivided into three more
categories:
Specification-based (black-box, also known as behavioral
techniques)
Structure-based (white-box or structural techniques)
Experience-based
Specification-based techniques include both functional and
non-functional techniques (i.e. quality characteristics).
Equivalence Partitioning
Equivalence Partitioning is also known as
Equivalence Class Partitioning.
Equivalence partitioning is a black-box testing
technique that applies to all levels of testing.
Equivalence class is a subset of data that is
representative of a larger class.
Divide input domain into equivalence classes.
One test case per equivalence class, to reduce total
number of test cases needed.
Equivalence Partitioning -
Example
You are filling an online application form
for a gym membership. The
only important criteria for getting a
membership is your age! Most of the gyms
have age criteria of 16-60, where you can
independently get the membership
without any supervision needed. If you
look at below membership form, you will
need to fill age first. After that, depending
on whether you are between 16-60, you
can go further. Otherwise, you will get a
message that you cannot get a
membership.
Equivalence Partitions - Example
• If we need to test this age field, the common sense tells us
that we need to test the values between 16-60, and values
which are less than 16, and some values which are more
than 60.
• It is easy to figure out, but what is not very evident is how
many combinations we need to test to say that the
functionality works safely?
• <16 has 15 combinations from 0-15, and if you test negative
values, then some more combination can be added
• 16-60 has 45 combinations
• >60 has 40 combinations (if you only take till 100)
Equivalence Partitions - Example
• Valid Partitions are values that should be accepted by the
component or system under test. This partition is called "Valid
Equivalence Partition."
• Invalid Partitions are values that should be rejected by the
component or system under test. This partition is
called "Invalid Equivalence Partition."
Equivalence Partitioning
Guidelines
Guidelines to define equivalence classes:
Range input : One valid and two invalid equivalence
Specific value : One valid and two invalid equivalence
A member of a set : One valid and one invalid
equivalence
Boolean : One valid and one invalid equivalence
Boundary Value Analysis
BVA is an extension of equivalence partitioning.
The basis of BVA is testing the boundaries at partitions
or you can say the “edges” of equivalence classes.
In practice, more errors found at boundaries of
equivalence classes than within the classes. (E.g.,
a developer using >10 instead of >= 10 for a condition).
Equivalence partitioning alone was not sufficient to
catch such defects.
Boundary Value Analysis -
Example
• Identify Exact Boundary Value of this partition Class - which is 16
& 60
• Get the Boundary value which is one less than the exact
Boundary - which is 15 & 59
• Get the Boundary Value which is one more than the precise
Boundary - which is 17 & 61
• If we combine them all, we will get below combinations for
Boundary Value for the Age Criteria.
Valid Boundary Conditions: Age = 16, 17, 59, 60
Invalid Boundary Conditions: Age = 15 and 61
Range of Boundary Values
1. Value immediately below range
2. First value of range
3. Second value of range
4. Value immediately below last value of
range
5. Last value of range
6. Value immediately above range
Example
In an examination, a candidate has to score a minimum of
24 marks in order to clear the exam. The maximum that
he can score is 40 marks.
Out of the given inputs, identify the valid only
equivalence values if the student clears the exam.
22, 23, 26
21, 39, 40
29, 30, 31
0, 15, 22
Example
In an examination, a candidate has to score a minimum of
24 marks in order to clear the exam. The maximum that
he can score is 40 marks.
Out of the given inputs, identify the invalid only
equivalence values if the student clears the exam.
30, 35, 36
24, 39, 40
29, 30, 31
0, 15, 22
Error Guessing
Based on the theory that test cases can be
developed based upon the intuition and
experience of the Test Engineer.
In an example where one of the inputs is
the date, the tester may try
February 29, 2000 or 9/9/9999
White Box Testing – Example
FindMean(float Mean, FILE ScoreFile)
{ SumOfScores = 0.0; NumberOfScores = 0; Mean = 0;
Read(ScoreFile, Score); /*Read in and sum the scores*/
while (! EOF(ScoreFile) {
if ( Score > 0.0 ) {
SumOfScores = SumOfScores + Score;
NumberOfScores++;
}
Read(ScoreFile, Score);
}
/* Compute the mean and print the result */
if (NumberOfScores > 0 ) {
Mean = SumOfScores/NumberOfScores;
printf("The mean score is %f \n", Mean);
} else
printf("No scores found in file\n");
WBT Example: Determining the
Paths
FindMean (FILE ScoreFile)
{ float SumOfScores = 0.0;
int NumberOfScores = 0;
1
float Mean=0.0; float Score;
Read(ScoreFile, Score);
2 while (! EOF(ScoreFile) {
3 if (Score > 0.0 ) {
SumOfScores = SumOfScores + Score;
4
NumberOfScores++;
5 }
Read(ScoreFile, Score); 6
}
/* Compute the mean and print the result */
7 if (NumberOfScores > 0) {
Mean = SumOfScores / NumberOfScores;
printf(“ The mean score is %f\n”, Mean); 8
} else
printf (“No scores found in file\n”); 9
Constructing the Logic Flow
Diagram
Start
F
2
T
3
T F
4 5
7
T F
8 9
Exit
Finding the test cases
Start
1
a (Covered by any data)
2
c b (Data set must contain at least one value)
(Positive score) d 3
e (Negative score)
4 5
(Data set must g h (Reached if either f or
f
be empty 6 e is reached)
7 j (Total score > 0.0)
(Total score < 0.0) i
8 9
k l
Exit
Control Flow
If you are flying with an economy ticket, there is a
possibility that you may get upgraded to business
class, especially if you hold a gold card in the
airline's frequent flier program. If you don't hold a
gold card, there is a possibility that you will get
'bumped' off the flight if it is full and you check in
late.
Control Flow Diagram
Note that each box (i.e. statement) has been numbered.
Statement Testing and Coverage
Statement
An entity in a programming language, which is
typically the smallest indivisible unit of execution.
Synonyms: source statement
Statement testing
A white-box test technique in which test cases are
designed to execute statements.
Statement Testing and Coverage
Number of Statements = 3
Decision Testing and Coverage
Decision
A type of statement in which a choice between two or
more possible outcomes controls which set of actions
will result.
Coverage
It measures in some specific way the amount of
testing performed by a set of tests.
Decision Testing and Coverage
How we calculate the Coverage?
The basic coverage measure is:
where the 'coverage item' is what ever we have been
able to count and see whether a test has exercised or
used this item.
Decision Testing and Coverage
Decision Testing
A white-box test
technique in which
test cases are designed
to execute decision
outcomes.
Number of Decision= 2
Decision Testing and Coverage
Decision Coverage =
(Number decision
exercised)/(Total Number of
decision) x 100
Only two path required to
execute every decision in
diagram.
100% decision coverage
implies 100% Statement
coverage. (but not vice
versa)