ST Lab Manual
ST Lab Manual
S.No
LIST OF EXPERIMENTS
Consider an automated banking application. The user can dial the bank from a personal computer, provide a sixdigit Password and follow with a series of keyword commands that activate the banking function. The software
for the application accepts data in the following form:
Area Code
Blank or three-digit number
Prefix
Three-digit number, not beginning with 0 or 1
Suffix
Four-digit number
Password
Six-character alphanumeric
Commands
"Check status", "Deposit", "Withdrawal"
Design adhoc test cases to test the system
Design the test cases to test the above application using the following Black Box testing techniques:
BVA, Worst BVA, Robust BVA, Robust Worst BVA, Equivalence class testing
Page No
11
Consider an application that is required to validate a number according to the following simple rules:
1. A number can start with an optional sign.
2. The optional sign can be followed by any number of digits.
3. The digits can be optionally followed by a decimal point, represented by a period.
4. If there is a decimal point, then there should be two digits after the decimal.
5. Any number-whether or not it has a decimal point, should be terminated a blank.
6. A number can start with an optional sign.
7. The optional sign can be followed by any number of digits.
8. The digits can be optionally followed by a decimal point, represented by a period.
9. If there is a decimal point, then there should be two digits after the decimal.
10. Any number-whether or not it has a decimal point, should be terminated a blank. Generate test cases to test
valid and invalid numbers.
Generate test cases using Black box testing technique to Calculate Standard Deduction on
Taxable Income. The standard deduction is higher for tax payers who are 65 or older or blind. Use the method
given below to calculate tax.
24
1. The first factor that determines the standard deduction is the filing status. The basic standard deduction for the
various filing status are:
4
Single
$4,750
Married, filing a joint return
$9,500
Married, filing a separate return $7,000
2. If a married couple is filing separate returns and one spouse is not taking standard Deduction, the other spouse
also is not eligible for standard deduction.
3. An additional $1,000 is allowed as standard deduction, if either the filer is 65 yrs or the spouse is 65 yrs or
older
4. An additional $1,000 is allowed as standard deduction, if either the filer is blind or the spouse is blind.
Consider A program segment which calculates the maximum value among three integers.
a) Draw the control flow graph for this program segment
b) Determine the cyclomatic complexity for this program
c) Determine the independent paths.
For a Source code of simple insertion sort implementation using array in ascending order in c programming
language,
a) Draw the program graph for given program segment b) Determine the DD path graph
c) Determine the independent paths
d) Generate the test cases for each independent path
Consider a system having an FSM for a stack having the following states and transitions:
States
Holding: Number of elements > 0, but less than the maximum capacity
30
36
41
WISE
10
11
12
For a given fragment of program code, calculate the number of tests required for 100% decision coverage? Also
write the test cases.
44
Given the following code, how much minimum number of test cases is required for full statement and branch
coverage?
48
read p read q
if p+q> 100
then print "Large" endif
if p > 50
then print "p Large" endif
Consider a program to input two numbers and print them in ascending order given below. Find all du paths and
Identify those du-paths that are not feasible. Also find all dc paths and generate the test cases for all paths (dc
paths and non dc paths).
55
Consider the above program and generate possible program slices for all variables. Design at least one test case
from every slice.
57
Consider the code to arrange the numbers in ascending order. Generate the test cases for relational coverage, loop
coverage and path testing. Check the adequacy of the test cases through mutation testing and also compute the
mutation score
60
for each.
i = 0;
n=4; //N-Number of nodes present in the graph
While (i<n-1) do j = i + 1;
While (j<n) do
if A[i]<A[j] then swap (A[i], A[j]); end do;
i=i+1;
end do
WISE
Exp No-1:PROBLEM STATEMENT:Consider an automated banking application. The user can dail the bank from a personal
computer, provide a six digit password and follow with a series of keyword commands that
activate the banking function the software for the application accepts data in the following form.
Area code
prefix
suffix
password
Commands
check status,deposit,withdraw
EXPECTED OUTPUT
111
accepted
WISE
TEST CASE2:
INPUT
EXPECTED OUTPUT
abc
accepted
ANALYSIS:-defects found
TEST CASE3:
INPUT
EXPECTED OUTPUT
Ab1
not accepted
EXPECTED OUTPUT
Ab1
Not accepted
WISE
TEST CASE2:
INPUT
EXPECTED OUTPUT
231
accepted
EXPECTED OUTPUT
40a
accepted
EXPECTED OUTPUT
WISE
9489
accepted
EXPECTED OUTPUT
12ab
accepted
EXPECTED OUTPUT
abc
Not accepted
EXPECTED OUTPUT
WISE
1@bcd1
accepted
TEST CASE2:
INPUT
EXPECTED OUTPUT
12345a
accepted
EXPECTED OUTPUT
123456
accepted
WISE
TEST CASE1:
INPUT
EXPECTED OUTPUT
last 10 transaction
EXPECTED OUTPUT
Last 12 transactions
EXPECTED OUTPUT
Deposit 80,000
accepted
WISE
INPUT
EXPECTED OUTPUT
Deposit 20,000
accepted
Withdraw:-minimum amount in the account should be 100 and max withdraw should not
exceed 5000/- at a time minimum balance present is 10,000/TEST CASE1:
INPUT
EXPECTED OUTPUT
Draw 6000
Not accepted
EXPECTED OUTPUT
Draw 4000
accepted
WISE
10
WISE
11
Exp No-2:Consider an automated banking application the user can dial the bank form a personal computer
provide a six digits password and follows with a series of keyword command that activated the
banking application accept data in the following them:
Area code
Blank of three digits number
Prefix
Three digits number not beginning with 0(or)1
Suffix
Four digits number
Password
Six character alphanumeric
Commands
Checkpoint Deposit Withdrawal
AIM: To design a Black box testing for the banking application
Description:
In black box testing there are two cases
1. Boundary value analysis:
In boundary value analysis we can check the tests at the boundary values it mean that
upper limit and lower limit and surrounding the boundary values along with middle values
2. Equivalence class partitioning:
In equivalence class partitioning we cannot check the all the combination of inputs we
divide the entire class of inputs into true class and false class
Boundary Value Analysis:
Area Code: Blank or 3-Digit Number
Minimum input value: Blank
Maximum input value: 3-digit number
Test Data:
min
max
Min+1
Min-1
Max+1
Max-1
Min+ Max/2
0
123
1
1234
12
23
WISE
12
Expected Output
rejected
rejected
rejected
Analysis: No defects in the test case .So test case will be closed.
Testcase2:
Input
123
124
Expected Output
Accepted
Accepted
Accepted
Expected Output
rejected
rejected
Accepted
234
034
2345
WISE
13
Min-1
Max+1
Max-1
Min + Max/2
23
345
03
345
Expected Output
rejected
rejected
rejected
Expected Output
Accepted
Accepted
Accepted
Expected Output
rejected
rejected
Accepted
1111
1142
WISE
14
Min+1
Min-1
Max+1
Max-1
Min+ Max/2
11115
111
11423
114
1134
Expected Output
rejected
rejected
rejected
Expected Output
Accepted
Accepted
Accepted
Expected Output
rejected
rejected
Accepted
Abcd12
1142ab
Abcd123
WISE
15
Min-1
Max+1
Max-1
Min+ Max/2
Abcd1
1142abc
1142a
Abc123
Expected Output
rejected
rejected
rejected
Expected Output
Accepted
Accepted
Accepted
Expected Output
rejected
rejected
Accepted
WISE
16
1124
2341
11241
12341
112
234
1124
Test case 1:
Input
1124
2341
Expected output
Accepted
Accepted
Analysis: No defects in this test case so we can close the test case
Test case2:
Input
12341
11241
Expected output
Rejected
Rejected
Analysis: No defects in this test case so we can close the test case
Test case for deposit: minimum and maximum inputs are as follows
Test case data:
Min=10,000
Max=40,000
Min
Max
Min+1
Max+1
Min-1
Max-1
Min+ max/2
1124
2341
11241
12341
112
234
1124
WISE
17
Test case 1:
Input
10,000
40,000
Expected output
Accepted
Accepted
Analysis: No defects in this test case so we can close the test case
Test case2:
Input
999
39,999
Expected output
Rejected
Rejected
Analysis: No defects in this test case so we can close the test case
Test case for withdrawl: minimum and maximum inputs are as follows
Test case data: Account Balance 1000
Min=100
Max=500
Min
Max
Min+1
Max+1
Min-1
Max-1
Min+ max/2
100
501
1001
499
999
775
Input
500
100
Expected output
Accepted
Accepted
500
Test case 1:
WISE
18
Analysis: No defects in this test case so we can close the test case
Test case2:
Input
999
39,999
Expected output
Rejected
Rejected
Analysis: No defects in this test case so we can close the test case
False class
4112
Abcd
1239
-
Test case 1:
Input
Expected outcome
411
Analysis: no defect in the test case so it can be closed
accepted
Test case 2:
Input
1239
Analysis: no defect in the text case it can be close
Expected outcome
Reject
False class
011
101
1234
WISE
19
427
1111
Test case 1:
Input
Expected outcome
421
accepted
Analysis: no defect in this close so we can close it
Test case 2:
Input
Expected outcome
01234
reject
Analysis: no defect in this close so we can close it
False class
12ab
Abcd
121cde
14abc
Test case 1:
Input
1298
Expected outcome
Accepted
Expected outcome
Reject
WISE
20
Input
1rbace
Expected outcome
Reject
False class
Abcde
123456
000000
111111
Test case 1:
Input
123abc
Expected outcome
Accept
Expected outcome
Reject
Expected outcome
Reject
WISE
21
False class
01
123
1
@456
12345
Input
1234
123
Expected outcome
Accepted
Accepted
Test scenario :
Test case 1:
Expected outcome
Not Accepted
False class
100
999
678
50100
60000
-
WISE
22
Expected outcome
Not Accepted
Not accepted
Testcase2:
Analysis: no defect in this test case so we can close it
WISE
23
Test case 3:
Input
Expected outcome
60000
10
Accepted
accepted
False class
10
6000
10000
51700
99
90000
Expected outcome
Accept
Expected outcome
WISE
24
Not Accepted
Expected outcome
Accepted
WISE
25
Exp No-4:Generate test case using black box testing technique to calculate standard deduction on taxable
income. The standard deduction is higher for tax payers who are 65 or older or blind use the
method given below to calculate maximum.
1. The first factor that determines the standard deduction is filling status the basic standard
deduction the various filling standards are:
single
$4,750
Married filing or join $9500
return
Married filing or join $7000
return
2. If a married couple is filing separate returns and one spouse is not taking standard deduction.
The other spouse also is not elgible for standard deduction.
3. An additional $1000 is allowed as standard deduction, if either the file is 65years or the spouse
is 65years or older (the latter case applicable when the filing status is married and filing joint).
4. An additional $1000 is allowed is standard deduction, if either the filter is blind or the spouse
is blind (the latter case applicable when the filing status is married and filing joint).
Aim: to calculate standard deduction for tax payers by using black box testing.
Description:
Black box testing is a method of software testing that examines the functionality of an
application without peering into its internal structures or workings. This method of can be
applied to virtually every level of software testing unit, integration, system and acceptance.
Test case scenarios:
Age: higher for tax payers ,who are 65 or older or blind.
Min=max
Min-1
Max+1
65
65-1=64
65+1=66
WISE
26
blind
Min=max
Min-1
Max+1
Input
Blind
4750
4750-1=4749
4750+1=4751
Test case 1:
Expected outcome
accepted
Expected outcome
60
rejected
Analysis: No defect test case2 can be closed
Test case 1:
Input
$4750
Expected outcome
accepted
Expected outcome
$4749
rejected
Expected outcome
rejected
WISE
27
Join-Return: $9500
Test case 1:
Input
$9500
Expected outcome
accepted
Expected outcome
rejected
Expected outcome
rejected
Expected outcome
accepted
Expected outcome
rejected
WISE
28
Expected outcome
rejected
Both
one
Test case 1:
Input
both
Expected outcome
accepted
Expected outcome
rejected
Expected outcome
rejected
65
WISE
29
Max+1
Min-1
65+1=66
65-1=64
Test case 1:
Input
70
Expected outcome
accepted
Expected outcome
rejected
Expected outcome
rejected
2
2-1=1
Test case 1:
Input
Both blind
Expected outcome
accepted
Expected outcome
accepted
WISE
30
Expected outcome
rejected
Viva questions:
1. What is black box testing?
WISE
31
WISE
32
DESCRIPTION:
sequence
selection
iteration
1. x=5
1. if x<y
1. x=0
2.y=x*x
2. x=x+y
2. while(count>0)
3. else x=x*y;
3. x=x+5
4. printf("%d",x);
count=count-1
a1
4. printf("%d",x);
1
4
2
WISE
33
WISE
34
Cyclomatic complexity:
It is a metric used for measuring the complexity of a given program code with respect to
dependent and independent paths in a control flow graph (coupling and cohesion). It can be
calculate in three ways:
1. The total number of predictive node is equal to the cyclomatic complexity of the program.
2. The total number of independent paths equal the cyclomatic complexity.
3. By calculating the total number of nodes and edges in the control flow graph using formula:
no. of edges-no. of nodes+2(E-N+2)
Independent path:
Independent path through the program it introduces at least one new edge that is not
included in any other path before it.
p1:1->2->3->8->9
p2:1->2->3->4->5->6->7->9
p3:1->2->3->4->5->6->5->9
Program:
a. control flow graph
1
WISE
35
3
4
5
10
b. cyclomatic complexity:
Here, N=10 and E=12
E-N+2
=12-10+2
=2+2
=4
c. independent paths:
path1:1->2->3->4->5->9
path2:1->2->3->4->5->6->9
path3:1->2->3->4->7->8->9
path4:1->2->3->4->5->7->8->9
WISE
36
Viva Questions:
1) What is cyclomatic complexity?
2) What is an independent path?
3) What is control flow graph?
4) What are the loops?
5) Difference between the independent path and dependenth path.
WISE
37
Exp No-6:Aim: Source code of simple insertion sort implementation using array in ascending order in c
programming language.
Description:
#include<stdio.h>
int main ()
{
int i, j, s, temp, a [20];
Printf (enter total elements :);
Scanf (%d, &s);
Printf (enter %d elements: s);
for (i=0; i<s; i++)
Scanf (%d, &a[i]);
for (i=1; i<s; i++)
Temp=a[i];
j=i-1;
While ((temp<a[j]) && (j>=0))
{
a [j+1] =a[j];
j=j-1;
WISE
38
}
a [j+1] =temp;
}
Printf (after sorting);
For (i=0; i<s; i++)
Printf (%d, a[i]);
Return o;
}
Test scenario:
a)
b)
c)
d)
Selection statements
4
5
6
7
for
for
9
100100
111
12
WISE
39
for
13
while
141
151
161
171
181
191
20
21
22
for
23
24
25
WISE
40
18
Test case1:
Input
i=1
Output
True
Test case2:
Input
i=6
Output
True
WISE
41
Input
i=0
Output
True
10
11
12
13
Test case2:
Input
i=6
Output
False
VIVA QUESTIONS:
1) What is Sorting?
2) What is DD path?
3) What is Independent path?
WISE
14 15
42
Exp No-7:Consider a system having FSM for a stack having the following states and transactions
States:
Initial: before creation
Empty: no of elements=0
Holding, no of elements>0, but<the max capacity
Full: no of elements =maximum
Final: after destruction
Initial to empty: create
Empty to holding, empty to full, holding to holding to full: Add
Empty to final, full to final, holding to final: destroy
Holding to empty, full to holding full to empty
Delete
AIM: To write a test case for a system having FSM for a stack
DESCRIPTION: FSM is a mathematical model of computation used to design both computer
programs and sequential logic circuits. A particular FSM is defined by list of its states, and the
triggering condition for each transition behavior of state machines can be observed in many
devices.
Test case: 1
Condition:
Initial: before creation
Analysis: Test case is successful before creation
Condition: Empty no of elements =0
Test case: 1
WISE
43
Elements=0
true
false
true (locked)
maximum=3
Elements=3
True (unlocked)
coin
push
Locked
initial
Unlocked
coin
pus
h
Condition: add
Test case: 1
WISE
44
Elements: 3
unlocked
unlocked
locked
locked
Initial
add
Holding
Empty
delete
add
delete
delete
delete
destroy
Final
Full
destroy
WISE
45
WISE
46
Exp No-8:AIM:
Given the following fragment of code. How many tests are required for 100% decision
coverage? Give the test cases
If width > length
Then biggest_dimension=width
If height > width then
Biggest_dimension=height
End-if
Else if biggest_dimension=length then
If height > width
Then biggest_dimension=height
End-if
End-if
End-if
Code segment:
If(width>length)
{
Biggest_dimension=width;
If(height>width)
{
Biggest_dimension=height;
}
}
WISE
47
Else if (dimension=length)
{
If(height>length)
Biggest_dimension=height
}
}
Aim:to generate the test cases for 100% decision coverage
Description: to every decision condition should be in test cases is called 100% decision
coverage.
Condition:
output
true
biggest_dimension=width=10
height > width
testcase1:
input
3>10
Output
False
Testcase1:
WISE
48
input
10>6
output
true
height>width
Testcase1:
input
15>10
output
true
width>length
Testcase1:
input
10>6
output
true
output
true
input
10>11
output
true
width>length
Testcase1:
WISE
49
output
true
output
true
Width>height
true
Width>length
false
Dimension=lengt
h
false
true
fals
Biggest_dimension=
height
Height>length
false
WISE
50
Exp No-9:Aim:
Give the following code,how much minimum number of test cases required for full statement
and
branch
Out
of coverage.
loop
Read pread 2
Biggest_dimension=h
eight
If p+q>100
Out of loop
WISE
51
}
If(p>50)
{
Printf(plarge);
Else
{
Printf(psmall);
}
}
Description:
The statement coverage also known as line coverage or segment coverage.The statement
coverage along the true conditions.Through statement coverage we can identify the statements
executed and where the code is not executed because of blockage.In this process each and every
line of code needs to be closed and executed.
Branch testing:
It is a testing method which aims to ensure that each one of the possible branch from each
decision point executed atleast once and there by ensuring that all reachable code executed.
That is every branch taken each lay true and false.it helps in validating all the branches in
the code making sure that no branch leads to abnormal behavior of the application.
WISE
52
Read p,q
p
2
Print p+q large
5
P is large
6
13
13
10
14
14
15
11
1
16
16
18
18
22
22
24
III Year II
Sem
24
WISE
53
Test-cases:
Condition:#include<stdio.h>(header file)
Test case:1
Input
Expected outcome
#include<stdio.h>
false
Expected outcome
#include<stdio.h>
Accepted
Expected outcome
WISE
54
Float p;
Rejected
Analysis: Test case executed successfully
Condition:
Int q;
Test case:1
Input
Expected outcome
Int q;
Accepted
Analysis: Test case executed successfully
Test case:2
Input
Expected outcome
Char q;
Rejected
Analysis: Test case executed successfully
Condition:
P+q>100;
Test case:1
Input
Expected outcome
P+q>100
Accepted
Analysis: Test case executed successfully
Test case:2
Input
Expected outcome
P+q=100
Rejected
Analysis: Test case executed successfully
WISE
55
Test case:3
Input
P+q<100
Analysis: Test case failed
Expected outcome
Accepted
Test case:4
Input
Expected outcome
P+q<100
Rejected
Analysis: Test case executed successfully
Condition:
Else
Test case:1
Input
Expected outcome
p&q are big
Accepted
Analysis: Test case failed
Test case:2
Input
Expected outcome
Accepted
Test case:1
Input
Expected outcome
WISE
56
p>50
Accepted
Analysis: Test case executed successfully
Test case:2
Input
p>50
Expected outcome
Rejected
Expected outcome
p<50
Accepted
Expected outcome
psmall
Accepted
Expected outcome
plarge
Rejected
WISE
57
WISE
58
Exp No-10:Aim:
To identify and write the test cases for all du-paths and dc-paths for a given program.
Description:
Calculation of du-paths and dc-paths comes under "Data Flow Testing", where the focus is
mainly laid on variables. We use variables in a program for
1) Receiving Values
2) Referencing in Calculations
3) Setting other variables.
du-path calculation:
A "definition-use(du)path" in a graph is a path in PATHS(P) such that for some v in V, there
exists DEF(v, m), USE( v, n) nodes where m, n are the initial and final nodes respectively.
dc-path calculation:
A "definition-clear(dc)path" w.r.t. a variable 'v' in a graph is a du-path in PATHS(P) where
the initial node of the path is the only defining node of v in the path.
WISE
59
WISE
60
Exp No-11:Aim:
To identify and write at least one test case for every program slice for a given program.
Description:
Program Slicing:
In computer programming, program slicing is the computation of the set of programs
statements, the program slice, that may affect the values at some point of interest, referred to
as a slicing criterion. Program slicing can be used in debugging to locate source of errors more
easily. Other applications of slicing include software maintenance, optimization, program
analysis, and information flow control.
At first, slicing was only static, i.e., applied on the source code with no other information than
the source code. Bogdan Korel and Janusz Laski introduced dynamic slicing, which works on
a specific execution of the program (for a given execution trace). Other forms of slicing exist,
for instance path slicing.
Unlike dc and du paths in Data Flow Testing, " Program Slicing" or "Slice Based Testing" is
also efficient in removing data flow anamolies for the given program.
Let us consider a program, P for a program graph, G(P) for a given set of variables, V. Then
slice of V at statement n - S(V, n). Here, we exclude all non-executable statements.
Slices are used in finding
1) Slice Composition
2) Relative complement of slices.
Slicing is categorized into
a) Static Slicing:
Based on the original definition of Weiser, informally, a static program slice S consists of all
statements in program P that may affect the value of variable v at some point p. The slice is
defined for a slicing criterion C=(x,V), where x is a statement in program P and V is a subset
of variables in P. A static slice includes all the statements that affect variable v for a set of all
possible inputs at the point of interest (i.e., at the statement x). Static slices are computed by
finding consecutive sets of indirectly relevant statements, according to data and control
WISE
61
dependencies.
Example: Consider the following program segment
int i;
int sum = 0;
int product = 1;
for(i = 1; i < N; ++i) {
sum = sum + i;
product = product * i;
}
write(sum);
write(product);
This new program is a valid slicing of the above program with respect to the criterion ( write
(sum) ,{sum}):
int i;
int sum = 0;
for(i = 1; i < N; ++i) {
sum = sum + i;
}
write(sum);
b) Dynamic Slicing:
Makes use of information about a particular execution of a program. A dynamic slice contains
all statements that actually affect the value of a variable at a program point for a particular
execution of the program rather than all statements that may have affected the value of a
variable at a program point for any arbitrary execution of the program.
An example to clarify the difference between static and dynamic slicing. Consider a small
piece of a program unit, in which there is an iteration block containing an if-else block. There
are a few statements in both the if and else blocks that have an effect on a variable. In the case
of static slicing, since the whole program unit is looked at irrespective of a particular
execution of the program, the affected statements in both blocks would be included in the
slice.
But, in the case of dynamic slicing we consider a particular execution of the program, wherein
the if block gets executed and the affected statements in the else block do not get executed. So,
that is why in this particular execution case, the dynamic slice would contain only the
WISE
62
#include<stdio.h>
#include<conio.h>
1. void main ()
2. {
3 int a, b, t;
4. Clrscr ();
5. Printf (Enter first number);
6. scanf (%d,&a);
7. printf(Enter second number);
8. scanf(%d,&b);
9. if (a<b){
10. t=a;
11. a=b;
12. b=t;
13. }
14. printf (%d %d, a, b);
15 getch ();
}
Test Cases for variables:
1) Variable 'a':
a) Successful reading of variable a
b) Unsuccessful reading of variable a(Memory problem)
2) Variable 'b':
a) Successful reading of variable b
b) Unsuccessful reading of variable b (incorrect format)
3) Variablet:
a) Successful reading of variable t
b) Unsuccessful reading of variable t(garbage value problem)
WISE
63
Exp No-12:Aim:
To identify and write the test cases for relational coverage ,loop coverage and path testing.
Apply Mutuation testing and derive the mutuation score for each test case.
Description:
1) Relational Operator Coverage
This metric reports whether boundary situations occur with relational operators (<, <=, >, >=).
The hypothesis is that boundary test cases find off-by-one mistakes and uses of the wrong
relational operators such as < instead of <=. For example, consider the following C code
fragment:
Eg: if (a < b)
Statement;
Relational operator coverage reports whether the situation a==b occurs. If a==b occurs and the
program behaves correctly, you can assume the relational operator is not suppose to be <=.
2) Loop Coverage
This metric reports whether you executed each loop body zero times, exactly once, and more
than once (consecutively). For do-while loops, loop coverage reports whether you executed the
body exactly once, and more than once.
The valuable aspect of this metric is determining whether while-loops and for-loops execute
more than once, information not reported by other metrics.
WISE
64
3) Path Coverage
This metric reports whether each of the possible paths in each function have been followed. A
path is a unique sequence of branches from the function entry to the exit.Also known as
predicate coverage. Predicate coverage views paths as possible combinations of logical
conditions.
Since loops introduce an unbounded number of paths, this metric considers only a limited
number of looping possibilities. A large number of variations of this metric exist to cope with
loops. Boundary-interior path testing considers two possibilities for loops: zero repetitions and
more than zero repetitions. For do-while loops, the two possibilities are one iteration and more
than one iteration.
Path coverage has the advantage of requiring very thorough testing. Path coverage has two
severe disadvantages. The first is that the number of paths is exponential to the number of
branches. For example, a function containing 10 if-statements has 1024 paths to test. Adding just
one more if-statement doubles the count to 2048. The second disadvantage is that many paths are
impossible to exercise due to relationships of data. For example, consider the following C code
fragment:
Eg: if (success)
statement1;
statement2;
If (success)
statement3;
Path coverage considers this fragment to contain 4 paths. In fact, only two are feasible:
success=false and success=true.
4) Mutation Testing:
Mutation testing is a technique that focuses on measuring the adequacy (quality) of test data (or
test cases). Here, we modify a program by introducing a single small change to the code.
Points to remember:
WISE
65
A mutant is said to be killed when the execution of test case cause it to fail. The mutant is
considered to be dead
A mutant is an equivalent to the given program if it always produce the same output as
the original program
A mutant is called killable or stubborn, if the existing set of test cases is insufficient to
kill it
A mutation score for a set of test cases is the percentage of non-equivalent mutants killed
by the test suite
WISE
66
WISE