Software Testing Methodologies
Student Notes
Unit 1
STM
Software Testing Methodologies
What is meant by statement coverage (C1) and branch coverage (C2)? Explain with
an example, how to select enough paths to achieve C1+C2.
A path through a program is a sequence of instructions or statements that starts at
an entry (or junction, or decision) and ends at another exit (or junction, or decision).
Paths consist of segments and the smallest segment is a link i.e., a single process that
lies between two nodes
The length of a path is by the number of nodes traversed
Path segment is a succession of consecutive links that belongs to some path
Fundamental Path Selection Criteria states that
exercise every
1. path from entry to exit.
2. statement or instruction at least once.
3. branch and case statement, in each direction, at least once.
PathTesting Criteria
Any testing strategy based on paths must at least both exercise every instruction and
take branches in all directions.
A set of tests that does this is not complete in an absolute sense, but it is complete in
the sense that anything less must leave something untested.
There are three different testing criteria or strategies out of a potentially infinite
family of strategies.
1. Path Testing
2. Statement Testing
3. Branch Testing
Statement Coverage
Execute all statements in the program at least once under some test. If we
do enough tests to achieve this, we are said to have achieved 100%
statement coverage (C1) This is the weakest criterion in the family: testing
less than this for new software is unconscionable and should be
criminalized.
Branch Coverage
Branch Testing (P2) Execute enough tests to assure that every branch
alternative has been exercised at least once under some test. If we do
enough tests to achieve this prescription, then we have achieved 100%
branch coverage (C2). For structured software, branch testing and
therefore branch coverage strictly includes statement coverage.
Sri Sivani college of Engineering
Software Testing Methodologies
Student Notes
Unit 1
Example
You must pick enough paths to achieve C1 + C2.
The question of what is the fewest number of such paths is interesting to the
designer of test tools that help automate path testing
As an example of how to go about selecting paths take any simple graph
Start at the beginning and take the most obvious path to the exitit typically
corresponds to the normal path.
Then take the next most obvious path (CHOOSE YOUR OWN/ANY EXAMPLE),
Other Suggesions are
Draw the control flowgraph on a single sheet of paper.
Make several copiesas many as youll need for coverage (C1 + C2) and several
more.
Highlight the paths bold letters
Continue tracing paths until all lines on the master sheet are covered, indicating that
you appear to have achieved C1 + C2.
As you trace the paths, create a table that shows the paths, the coverage status of each process, and
each decision
Suhrit Answers for
What is meant by a Loop? State and explain various kinds of Loops with suitable
examples. Also discuss how to select optimal paths for C1+C2.(Statement coverage +
Branch coverage)
Loop
Set of statements repeated for specified number of times or until it meets
specific condition is called as a Loop. For example print statement which is
included in a for loop executes n number of times based on condition in for
loop. There are four types of loops 1. Single Loop 2. Nested Loop 3.
Concatenated Loop 4. Horrible Loop
Single Loop
A simple loop that executes based on the following cases are considered as
single loop.
Case 1 Single Loop, Zero Minimum, N Maximum, No Excluded Values
for(i=0;i<=10;i++)
{
Sri Sivani college of Engineering
Software Testing Methodologies
Student Notes
Unit 1
printf(%d,i); // loop begins with 0 and ends with 10
}
Case 2
Single Loop, Nonzero Minimum, No Excluded Values
for(i=10;i<=20;i++)
{
printf(%d,i); // loop begins with 10 and ends with 20
}
Case 3
Single Loops with Excluded Values
for(i=1;i<=10;i+=2)
{ printf(%d,i); //loop excludes even numbers
}
Testing Strategies on Single Loop
Try one less than the expected minimum. Check boundary of control variable
The minimum number of iterations.
One more than the minimum number of iterations.
Once, unless covered by a previous test.
Twice, unless covered by a previous test.
A typical value.
One less than the maximum value.
The maximum number of iterations.
Attempt one more than the maximum number of iterations.
Nested Loop
Loop with in another loop can be called as Nested loop as like
for(i=1;i<=10;i+=2)
{
for(j=1;j<=10;j+=2)
{
printf(%d,i+j);
}
}
General Testing Strategies on Nested Loops
Start at the innermost loop. Set all the outer loops to their minimum values.
Test the minimum, minimum + 1, typical, maximum 1, and maximum for the
innermost loop.
If youve done the outermost loop, GOTO step 5, otherwise move out one loop and
set it up as in step 2with all other loops set to typical values.
Continue outward in this manner until all loops have been covered.
Do the five cases for all loops in the nest simultaneously
Concatenated Loops
Sri Sivani college of Engineering
Software Testing Methodologies
Unit 1
Student Notes
Concatenated loops fall between single and nested loops with respect to test cases.
Two loops are concatenated if its possible to reach one after exiting the other while
still on a path from entrance to exit.
If the loops cannot be on the same path, then they are not concatenated and can be
treated as individual loops.
Horrible Loops
The thinking required to check the end points and looping values for intertwined
loops appears to be unique for each program.
Its also difficult at times to see how deeply nested the loops are, or indeed whether
there are any nested loops.
The use of code that jumps into and out of loops, intersecting loops, hidden loops,
and crossconnected loops, makes iteration
value selection for test cases very difficult, an awesome and ugly task, which is
another reason such structures should be avoided.
To get optimal paths for C1+C2
You must pick enough paths to achieve C1 + C2.
The question of what is the fewest number of such paths is interesting to the
designer of test tools that help automate path testing
As an example of how to go about selecting paths take any simple graph
Start at the beginning and take the most obvious path to the exitit typically
corresponds to the normal path.
Then take the next most obvious path (CHOOSE YOUR OWN/ANY EXAMPLE),
Other Suggesions are
Draw the control flowgraph on a single sheet of paper.
Make several copiesas many as youll need for coverage (C1 + C2) and several
more.
Highlight the paths bold letters
Continue tracing paths until all lines on the master sheet are covered, indicating that
you appear to have achieved C1 + C2.
As you trace the paths, create a table that shows the paths, the coverage status of each process, and
each decision
Discuss about assignment blindness, and equality blindnesss of predicates.
Testing blindness is a pathological situation in which the desired path is achieved for
the wrong reason.
It can occur because of the interaction of two or more statements that makes the
buggy predicate work despite its bug
Sri Sivani college of Engineering
Software Testing Methodologies
Unit 1
Student Notes
There are three types of blindness, they are
1.
2.
3.
Assignment blindness
Equality blindness
Selfblindness
Assignment Blindness
Assignment blindness occurs when the buggy predicate appears to work correctly.
Specific value chosen for an assignment statement works with both the correct and
incorrect predicate.
For example:
Correct
testX=20;
..
if(testY>0)
{
Bug
testX=20;
.
if(testX+testY>0)
{
Equality Blindness
Equality blindness occurs when the path selected by a prior predicate results in a
value that works both for the correct and buggy predicate.
For example:
Correct
if(testY==20)
..
if(testX+testY>30)
{
Bug
if(testY==20)
.
if(testX>10)
{
Explain the terms achievable and unachievable paths.
If you can find a solution, then the path is achievable.
If you cant find a solution to any of the sets of inequalities the path is unachievable.
Based on the below steps check the possibility of solution
o
o
We want to select and test enough paths to achieve a satisfactory notion of
test completeness such as C1 and/or C2.
Extract the programs control flowgraph and select a set of tentative
covering paths.
Sri Sivani college of Engineering
Software Testing Methodologies
Student Notes
Unit 1
o
o
o
o
o
For any path in that set, interpret the predicates along the path as needed to
express them in terms of the input vector.
Trace the path through, multiplying (boolean) the individual compound
predicates to achieve a boolean expression.
Multiply out the expression to achieve a sumofproducts form
Each product term denotes a set of inequalities that, if solved, will yield an
input vector that will drive the routine along the designated path.
Solve any one of the inequality sets for the chosen path and you have found
a set of input values for the path.
The act of finding a set of solutions to the path predicate expression is called path
sensitization.
Sri Sivani college of Engineering