Software Testinglab Manual
Software Testinglab Manual
2013-14
SOFTWARE TESTING
LABORATORY
Subject Code: 10ISL68
25
Hours/Week: 03
I.A. Marks:
Exam Hours:
03
Total Hours: 42
50
Exam Marks:
Page
2013-14
Page
2013-14
(a + b) then do step 3
else
Department of ISE, DSCE-Bangalore
3
Page
2013-14
Page
2013-14
Page 5
2013-14
Not
Page
2013-14
a
for
for
for
for
for
for
for
for
Expecte
d
Outpu a
Not
Triangle
Not
a
Triangle
Not
a
Triangle
Equilateral
Isosceles
Isosceles
Isosceles
Scalene
Actual
Output
Status
Page 7
2013-14
4. No of TCs
Failed:
The decision table technique is indicated for applications
characterised by any of the following:
Prominent if-then-else logic
Logical relationships among input variables
Calculations involving subsets of the input variables
Cause-and-effect relationship between inputs and outputs
The decision table-based testing works well for triangle problem
because a lot of decision making i.e if-then-else logic takes place.
1.6 SNAPSHOTS:
1. Output screen of Triangle cannot be formed
Page 8
2013-14
1.7. REFERENCES:
Department of ISE, DSCE-Bangalore
Page 9
2013-14
1. Requirement Specification
2. Assumptions
Page
2013-14
Page
2013-14
Page
2013-14
{
printf("triangle cannot be formed");
}
getch();
return
0;
}
2.4 TESTING
1. Technique used: Boundary value analysis
2. Test Case design
For BVA problem the test cases can be generation
depends on the output and the constraints on the output.
Here we least worried on the constraints on Input domain.
The Triangle problem takes 3 sides as input and checks it
for validity, hence n = 3. Since BVA yields (4n + 1) test cases
according to single fault assumption theory, hence we can
say that the total number of test cases will be (4*3+1)
=12+1=13.
The maximum limit of each sides a, b, and c of the triangle
is 10 units according to requirement R4. So a, b and c lies
between
0a
10
0b
10
0c
10
Equivalence classes
for a:
E1: Values less than
1. E2: Values in the
range.
E3:
Values
greater
than 10.
Equivalence classes
for b:
E4: Values less
than 1.
Department of ISE, DSCE-Bangalore
13
Page
2013-14
6
7
Test
Case
For A input is
not given
For B input is
not
given
For C input is
not
given
Input of C is
in
negative(-)
Two sides are
Not a Triangle
Not a Triangle
-1
Not a Triangle
Isosceles
Equilateral
Isosceles
10 Not a Triangle
Status
Page 14
10
11
12
13
2013-14
Isosceles
Isosceles
Isosceles
10 5
Not a Triangle
Isosceles
Isosceles
Isosceles
14
15
different input
(i.e.,
B & are
C 2
Two sides
same one side
is
given
different input
(i.e.,
B & are
C 9
Two sides
same one side
is
Page 15
2013-14
given
16
different
input
(i.e., B
Two sides
are 10 5
same one side
is
given
Not a Triangle
different input
(i.e., B & C
are 5, A=10,
so the given
Table-1: Test case for Triangle Problem
2.5 EXECUTION:
Execute the program and test the test cases in Table-1
against program and complete the table with for Actual output
column and Status column
Test Report:
1. No of TCs Executed:
2. No of Defects Raised:
3. No of TCs Pass:
4. No of TCs Failed:
Page 16
2013-14
2.6 SNAPSHOTS:
1. Snapshot of Isosceles and Equilateral triangle and triangle
can not be formed.
Page 17
2013-14
Page 18
2013-14
2.7 REFERENCES:
1. Requirement Specification
2. Assumptions
Page 19
2013-14
Page
2013-14
ALGORITHM:
Step 1: Input a, b & c i.e three integer values which represent
three sides of the triangle.
Step 2: if (a < (b + c)) and (b < (a + c)) and (c <
(a + b) then do step 3
else
print not a triangle. do step 6.
Step 3: if (a=b) and (b=c) then
Print triangle formed is equilateral. do step 6.
Step 4: if (a b) and (a c) and (b c) then
Print triangle formed is scalene. do
step 6. Step 5: Print triangle formed
is Isosceles. Step 6: stop
3.3 PROGRAM CODE
#include<stdio.h>
#include<ctype.h>
#include<conio.h>
#include<process.h>
int main()
{
int a, b, c;
clrscr();
printf("Enter three sides of the triangle");
scanf("%d%d%d", &a, &b, &c);
if((a > 10) || (b > 10) || (c > 10))
{
printf("Out of range");
getch();
exit(0);
}
if((a<b+c)&&(b<a+c)&&(c<a+b))
{
Department of ISE, DSCE-Bangalore
21
Page
2013-14
if((a==b)&&(b==c))
{
printf("Equilateral triangle");
}
else if((a!=b)&&(a!=c)&&(b!=c))
{
printf("Scalene triangle");
}
els
e
printf("Isosceles triangle");
}
els
e
{
printf("triangle cannot be formed");
}
getch();
return
0;
}
3.4 TESTING
1. Technique used: Equivalence class partitioning
2. Test Case design
Equivalence class partitioning technique focus on the Input
domain, we can obtain a richer set of test cases. What are
some of the possibilities for the three integers, a, b, and c?
They can all be equal, exactly one pair can be equal.
The maximum limit of each side a, b, and c of the triangle
is 10 units according to requirement R4. So a, b and c lies
between
0a
10
0b
10
0c
10
Page
2013-14
First Attempt
Weak normal equivalence class:
In
the
problem
statement, we note that four possible outputs can occur:
Not a Triangle, Scalene, Isosceles and Equilateral.
We
can
use these
to
identify
output
(range) equivalence classes as follows:
R1= {<a,b,c>: the triangle with sides a, b, and c is
equilateral} R2= {<a,b,c>: the triangle with sides
a, b, and c is isosceles}
R3= {<a,b,c>: the triangle with sides a, b, and c is
scalene}
R4= {<a,b,c>: sides a, b, and c do not form a triangle}
Four weak normal equivalence class test cases, chosen
arbitrarily from each class, and invalid values for weak
robust equivalence class test cases are as follows.
TC Test
Id
Case
1
WN1
Equilateral
WN2
Isosceles
WN3
Scalene
WN4
Not a Triangle
WR1
-1
WR2
-1
WR3
-1
WR4
11 5
Value of a is not
the range of
permitted
values of b is not
Value
the range of
permitted
values of c is not
Value
the range of
permitted
values of a is not
Value
the range of
permitted
values
Actual
Output
Statu
s
in
in
in
in
Page
2013-14
WR5
11
10
WR6
11
Value of b is not in
the
range of
permitted
Value of
c is not in
the range of
permitted
values
Table-1: Weak Normal and Weak Robust Test case for Triangle
Problem
Second attempt
The strong normal equivalence class test cases can be
generated by using following possibilities:
D1 = {<a, b, c>:
a=b=c}
D2 = {<a, b, c>:
a=b, a c} D3=
{<a, b, c>: a=c, a
b} D4 = {<a, b, c>:
b=c, a b}
D5 = {<a, b, c>: a b,
a c, b c}
D6 = {<a, b, c>:
a b+ c} D7 =
{<a, b, c>: b a+
c} D8 = {<a, b, c>:
c a+ b}
TC Test
Input Data Expected Output
Actual
Id
Output
a
b
c
Case
Descripti
1
SR1
-1 5
5
Value of a is not in
the range of
permitted
values of b is not in
2
SR 2
5
-1 5
Value
the range of
permitted
values of c is not in
3
SR3
5
5
-1 Value
the range of
permitted
values
Statu
s
SR4
-1
-1
Value of a, b is
not in
the range of
permitted values
Page
2013-14
SR5
-1
-1
SR6
-1
-1
SR7
-1
-1
-1
Value of b, c is not in
the
range of
Value ofpermitted
a, c is not in
the range of
permitted
values
Value of a, b, c is
not in the range of
permitted values
3.5 EXECUTION:
Execute the program and test the test cases in Table-1 and
Table-2 against program and complete the table with for Actual
output column
and
Status column
Test Report:
1.
2.
3.
4.
No
No
No
No
of
of
of
of
TCs Executed:
Defects Raised:
TCs Pass:
TCs Failed:
Page
2013-14
3.6 SNAPSHOTS:
1. Snapshot of Equilateral. Isosceles and scalene triangle.
Page 26
2013-14
3. Snapshot for the given range is Out of range and Triangle cannot
be formed.
Page 27
2013-14
3.7 REFERENCES
1. Requirement Specification
2. Assumptions
Page
2013-14
m
STEP 1: Define
barrelPrice=25.0
STEP2:
locks
lockPrice=45.0,
stockPrice=30.0,
Input
Page
2013-14
Page
2013-14
Page
2013-14
is
%d
\n
The
commission
is
Page
2013-14
catogar
c-y
use
puse
flag
Page 33
2013-14
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
t_sales
locks, stocks,
barrels
t_sales
commission
t_sales
t_sales
commission
commission
commission
commission
commission
commission,
t_sales
commission
commission,
t_sales
commission
Page 34
definition - use
pair
start line end line
910
910
910
920
920
920
1214
2021
2023
2025
2028
2034
2336
2728
2836
3233
3334
3436
2013-14
cuse
variables
()
lock
s
stock
s
barrel
s
puse
locks
stock
s
barrel
s
flag
t_sale
s
t_sale
s
t_sale
s
t_sale
s
t_sale
s
commission
commission
commission
commission
commission
commission
Fig: define test
cases
Variable(
s)
locks,
stocks
,
barrel
locks,
stocks
,
barrel
Flag
dupai
920
Input
Expected
s
outputcommi
locks stock
barrel t_sale
sub
s
s
s
ss
9,10,20
10
10
10
1000
910
910
1214 1214
-1
22
Invalid Input
-1
40
45
Invalid Input
Page 35
t_sales
t_sales
commissio
n
commissio
n
commissio
n
2021
2025
2336
2736
3236
20,21
20,21,2
52336
27,28,3
6
32,33,3
4,
36
2013-14
5
15
5
15
25
5
15
5
15
25
5
15
5
15
25
500
1500
50
175
360
4.5 EXECUTION
Execute the program and test the test cases in above
Tables against program and complete the table with for Actual
output column
and
Status column
4.6 SNAPSHOTS:
1. Snapshot for Total sales and commission when total sales are
within 1000 and Invalid input
Page 36
2013-14
2. Invalid Input and Total sales and commission when total sales
are within
1000
3. Snapshot for for Total sales and commission when total sales
are within
1800 and to find out the total commission 360
Page 37
2013-14
4.7 REFERENCES
1. Requirement Specification
2. Assumptions
Page 38
2013-14
m
STEP 1: Define lockPrice=45.0, stockPrice=30.0,
barrelPrice=25.0
Department of ISE, DSCE-Bangalore
39
Page
2013-14
commission = commission + 0.20 * (sales1800.0) STEP9: if (sales > 1000.0) goto STEP 10
else goto STEP 11
STEP10: commission=0.10* 1000.0;
commission=commission + 0.15 * (sales-1000.0)
STEP11: Output(Commission is $,
commission) STEP12: exit
5.3 PROGRAM CODE:
#include<stdio.h>
#include<conio.h>
int main()
{
int locks, stocks, barrels, t_sales, flag = 0;
float commission;
clrscr();
printf("Enter the total number of locks");
scanf("%d",&locks);
if ((locks <= 0) || (locks > 70))
{
flag = 1;
Department of ISE, DSCE-Bangalore
40
Page
2013-14
}
printf("Enter the total number of stocks");
scanf("%d",&stocks);
if ((stocks <= 0) || (stocks > 80))
{
flag = 1;
}
printf("Enter the total number of barrelss");
scanf("%d",&barrels);
if ((barrels <= 0) || (barrels > 90))
{
flag = 1;
}
if (flag == 1)
{
printf("invalid input");
getch();
exit(0);
}
t_sales = (locks * 45) + (stocks * 30) + (barrels * 25);
if (t_sales <= 1000)
{
commission = 0.10 * t_sales;
}
else if (t_sales < 1800)
{
commission = 0.10 * 1000;
commission = commission + (0.15 * (t_sales - 1000));
}
els
e
{
commission = 0.10 * 1000;
commission = commission + (0.15 * 800);
commission = commission + (0.20 * (t_sales - 1800));
Department of ISE, DSCE-Bangalore
41
Page
}
printf("The total sales
%f",t_sales, commission);
getch();
return;
}
2013-14
is
%d
\n
The
commission
is
5.4
TESTING
Technique used: Boundary value analysis
Boundary value analysis testing technique is used to
identify errors at boundaries rather than finding those exist in
center of input domain.
Boundary value analysis is a next part of Equivalence
partitioning for designing test cases where test cases are
selected at the edges of the equivalence classes.
BVA:
Procedure
1. Partition the input domain using unidimensional partitioning.
This leads to as many partitions as there are input variables.
Alternately, a single partition of an input domain can be created
using multidimensional partitioning. We will generate several subdomains in this step.
2. Identify the boundaries for each partition. Boundaries
may also be identified using special relationships amongst the
inputs.
3. Select test data such that each boundary value occurs in at
least one test input.
4.
BVA:
Example:
Create
equivalence classes
Assuming that an item code must be in the range 99...999 and
quantity in the range 1...100,
Equivalence classes for
code:
E1: Values less than
99. E2: Values in
the range.
Page
Software Testing
Laboratory
2013-14
Case
Page
43
2013-14
TC
Id
1
Test Case
Description
Input test cases
for
Locks=1,
Stocks=1,
Barrels=1
Input test cases
for
Locks=1,
Stocks=1,
Barrels=2
Input test cases
for
Locks=1,
Stocks=2,
Barrels=1
Input test cases
for
Locks=2,
Stocks=1,
Barrels=1
Input test cases
for
Locks=5,
Stocks=5,
Barrels=5
Input test cases
for Locks=10,
Stocks=10,
Input Data
Locks Stocks Barrels
Sales
Expected
Output(Commission)
100
10
125
12.5
130
13
145
14.5
500
50
10
10
975
97.5
Actual Status
Output
Page 44
10
11
12
13
14
15
16
Barrels=9
Input test cases
for Locks=10,
Stocks=9,
Barrels=10
Input test cases
for
Locks=9,
Stocks=10,
Barrels=10
Input test cases
for Locks=10,
Stocks=10,
Barrels=10
Input test cases
for Locks=10,
Stocks=10,
Barrels=11
Input test cases
for Locks=10,
Stocks=11,
Barrels=10
Input test cases
for Locks=11,
Stocks=10,
Barrels=10
Input test cases
for Locks=14,
Stocks=14,
Barrels=13
Input test cases
for Locks=18,
Stocks=18,
Barrels=17
Input test cases
for Locks=18,
Stocks=17,
Barrels=18
Input test cases
for Locks=17,
Stocks=18,
2013-14
10
10
970
97
10
10
955
95.5
10
10
10
1000
100
10
10
11
1025
103.75
10
11
10
1030
104.5
11
10
10
1045
106.75
14
14
13
1400
160
18
18
17
1775
216.25
18
17
18
1770
215.5
17
18
18
1755
213.25
Page 45
17
18
19
20
21
Barrels=18
Input test cases
for Locks=18,
Stocks=18,
Barrels=18
Input test cases
for Locks=18,
Stocks=18,
Barrels=19
Input test cases
for Locks=18,
Stocks=19,
Barrels=18
Input test cases
for Locks=19,
Stocks=18,
Barrels=18
Input test cases
for Locks=48,
Stocks=48,
Barrels=48
2013-14
18
18
18
1800
220
18
18
19
1825
225
18
19
18
1830
226
19
18
18
1845
229
48
48
48
4800
820
No
No
No
No
of
of
of
of
TCs Executed:
Defects Raised:
TCs Pass:
TCs Failed:
Page 46
2013-14
5.6 SNAPSHOTS:
1. Snapshot for valid inputs
Page 47
2013-14
3. Snapshots when the two inputs and all the inputs are same
5.7 REFERENCES
1. Requirement Specification
2. Assumptions
Department of ISE, DSCE-Bangalore
Page 48
2013-14
Page
2013-14
Page
2013-14
scanf("%d",&stocks);
if ((stocks <= 0) || (stocks > 80))
{
flag = 1;
}
printf("Enter the total number of barrelss");
scanf("%d",&barrels);
if ((barrels <= 0) || (barrels > 90))
{
flag = 1;
}
if (flag == 1)
{
printf("invalid input");
getch();
exit(0);
}
t_sales = (locks * 45) + (stocks * 30) + (barrels * 25);
if (t_sales <= 1000)
{
commission = 0.10 * t_sales;
}
else if (t_sales < 1800)
{
commission = 0.10 * 1000;
commission = commission + (0.15 * (t_sales - 1000));
}
els
e
{
commission = 0.10 * 1000;
commission = commission + (0.15 * 800);
commission = commission + (0.20 * (t_sales - 1800));
}
Page
2013-14
is
%d
\n
The
commission
is
6.4 TESTING
Technique
used:
Class testing
Equivalence
Page
Software Testing
Laboratory
2013-14
>12
00
Page
53
2013-14
CASE
B2 ={barrels:
barrels<1}
B3
={
barrels:
barrels>90}
Department of ISE, DSCE-Bangalore
54
Page
2013-14
One problem occurs, however. The variables lock are also used
as a sentinel to indicate no more telegrams. When a value of -1 is
given for locks, the while loop terminates, and the values of
totallocks, totalstocks and totalbarrels are used to compute sales,
and then commission.
Expect for the names of the variables and the interval endpoint
values, this is
identical to our first version of the NextDate function. therefore
we will have exactly one week normal equivalence class test case
and again, it is identical to the strong normal equivalence class
test case. Note that the case for locks =
-1 just terminates the
iteration.
First
attempt
We will have eight weak robust test
cases.
TC Test
Id
Case
WR1
1
Input Data
Sales
10
10
10
$100
WR2
-1
40
45
WR3
-2
40
45
WR4
71
40
45
WR5
35
-1
45
WR6
35
81
45
WR7
10
10
Program
terminates
Values of
locks not
in
the
range
1...70
Values of
locks not
in
the
range
1...70
Values of
stocks not
in
the
range
1...80
Values of
stocks not
in
the
range
1...80
970
Expected
Actual Statu
Output(Commissi Outpu s
on)
t
10
Program terminates
Values of locks not in the
range 1...70
97
WR8
10
10
955
95.5
Page 55
2013-14
Second attempt:
Finally, a corner of the cube will be in 3 space of the additional
strong robust equivalence class test cases:
TC Test Case Input Data
Sales
Id Description Locks Stocks Barrels
1
SR1
-2
40
45
SR2
35
-1
45
SR3
35
40
-2
SR4
-2
-1
45
SR5
-2
40
-1
SR6
35
-1
-1
SR7
-2
-1
-1
Values
not in
1...70
Values
not in
1...80
Values
not in
1...90
Values
not in
1...70
Values
not in
1...80
Values
not in
1...70
Values
not in
1...90
Values
not in
1...80
Values
not in
1...90
Values
not in
1...70
Values
not in
1...80
Values
not in
1...90
Expected
Actual Status
Output(Commission) Output
of locks Values of locks not in
the range the range 1...70
of stocks Values of stocks not
the range in the range 1...80
of barrels Values of barrels not
the range in the range 1...90
of locks Values of locks not in
the range the range 1...70
Values of stocks not
of stocks in the range 1...80
the range
of locks Values of locks not in
the range the range 1...70
Values of barrels not
of barrels in the range 1...90
the range
of stocks Values of stocks not
the range in the range 1...80
Values of barrels not
of barrels in the range 1...90
the range
of locks Values of locks not in
the range the range 1...70
Values of stocks not
of stocks in the range 1...80
the range Values of barrels not
in the range 1...90
of barrels
the range
Page 56
2013-14
6.5 EXECUTIONS
Execute the program and test the test cases in Table-1 against
program and complete the table with for Actual output column
and Status column
Test Report:
1.
2.
3.
4.
No
No
No
No
of
of
of
of
TCs Executed:
Defects Raised:
TCs Pass:
TCs Failed:
6.6 SNASHOTS
1. Snapshot for invalid inputs
Page 57
2013-14
2. Invalid Input and commission for when the all inputs are 10
Page 58
2013-14
6.7 REFERENCES
1. Requirement Specification
2. Assumptions
Page
2013-14
commission.
7.2
DESIGN:
Form the given requirements we can draw the following
conditions:
C1: 1locks70?
Locks = -1?
C1a: 1locks
C1b: locks70
Page
2013-14
C5:
sales>1000?
C6:
sales1000?
ALGORITHM
Step 1: Input 3 integer numbers which represents number of
Locks, Stocks and Barrels sold.
Step 2: compute the total sales =
(Number of Locks sold *45) + (Number of Stocks sold *30) +
(Number of
Barrels sold *25)
Step 3: if a totals sale in dollars is less than or equal to $1000
then commission = 0.10* total Sales do step 6
Step 4: else if total sale is less than $1800
then commission1 = 0.10* 1000
commission = commission1 + (0.15 * (total sales
1000))
do step 6
Step 5: else commission1 = 0.10* 1000
commission2 = commission1 + (0.15 * 800))
commission = commission2 + (0.20 * (total sales
1800)) do
step 6
Step 6: Print commission.
Step 7: Stop.
7.3 PROGRAM CODE:
#include<stdio.h>
#include<conio.h>
int main()
{
int locks, stocks, barrels, t_sales, flag = 0;
float commission;
Page
2013-14
clrscr();
printf("Enter the total number of locks");
scanf("%d",&locks);
if ((locks <= 0) || (locks > 70))
{
flag = 1;
}
printf("Enter the total number of stocks");
scanf("%d",&stocks);
if ((stocks <= 0) || (stocks > 80))
{
flag = 1;
}
printf("Enter the total number of barrelss");
scanf("%d",&barrels);
if ((barrels <= 0) || (barrels > 90))
{
flag = 1;
}
if (flag == 1)
{
printf("invalid input");
getch();
exit(0);
}
t_sales = (locks * 45) + (stocks * 30) + (barrels * 25);
if (t_sales <= 1000)
{
commission = 0.10 * t_sales;
}
else if (t_sales < 1800)
{
commission = 0.10 * 1000;
commission = commission + (0.15 * (t_sales - 1000));
Department of ISE, DSCE-Bangalore
62
Page
2013-14
}
else
{
commission = 0.10 * 1000;
commission = commission + (0.15 * 800);
commission = commission + (0.20 * (t_sales - 1800));
}
printf("The total sales
%f",t_sales, commission);
getch();
return;
}
is
%d
\n
The
commission
is
7.4
TESTING
Technique Used: Decision Table
Approach
The decision table is given
below
Conditions
Condition Entries
(Rules)
C1: 1locks70?
F
T T T T T
C2: 1stocks80?
-- F T T T T
C3: 1barrels90?
-- -- F T T T
C4: sales>1800?
-- -- -- T F F
C5: sales>1000?
-- -- -- -- T F
C6: sales1000?
-- -- -- -- -- T
Actions
Action Entries
a1: com1 = 0.10*Sales
X
a2:
com2
=
X
com1+0.15*(sales-1000)
a3:
com3
=
X
com2+0.20*(sales-1800)
a4: Out of Range.
X X X
Using the decision table we get 6 functional test cases: 3 cases
out of range, 1 case each for sales greater than $1800, sales
greater than $1000, sales less than or equal to $1000.
DERIVING TEST CASES USING Decision Table
Approach:
Test
Cases:
Page
5
6
7
8
9
Test
Case
Testing
Requirement 1
Condition 1 (C1)
Testing
Requirement 1
Condition 1 (C1)
Testing
Requirement 1
Condition 2 (C2)
Testing
Requirement 1
Condition 2 (C2)
Testing
Requirement 1
Condition 3 (C3)
Testing
Requirement 1
Condition 3 (C3)
Testing
Requirement 2
Testing
Requirement 2
Testing
Requirement 2
for
2013-14
Expected
Lock Stock Barrel
Output
s
s
s
-2
40
45
Out of Range
90
40
45
Out of Range
35
-3
45
Out of Range
35
100
45
Out of Range
35
40
-10
Out of Range
35
40
150
Out of Range
500
15
15
15
25
25
25
1500 a2:
175
2500 a3:
360
Actual
Status
Output
for
for
for
for
for
for
for
for
a1:50
Page 64
2013-14
Page 65
2013-14
7.7 REFERENCES:
1. Requirement Specification
2. Assumptions
Page
2013-14
Page
2013-14
Page
2013-14
high=mid-1;
}
}
if(flag==1)
printf("Successful
found at
%d\n",mid+1);
els
e
search\n
Location
Element
}
els
e
printf("Wrong input");
getch();
return 0;
}
8.4
TESTING
Technique Used: Basis Path
Testing
Basis path testing is a form of Structural testing (White Box
testing). The method devised by McCabe to carry out basis
path testing has four steps. These are:
1. Compute the program
graph.
2. Calculate
complexity.
the
cyclomatic
Page
2013-14
10
11
12
13
14
15
16
17
18
19
20
21
28
22, 23
29,
30
24, 25
31
32, 33
34, 35
26,
27
40
37
38
41
Page
2013-14
DD Path Name
5
6,7,8,9,10
11
12,13,14
15,16,17
18
19,20
37
21
22,23,24,25,26,27
28
29.30,31
32,33,34,35
38
40
41
C
D
H
J
G
M
N
O
Page
2013-14
semantically feasible
if n value is
0.
P2: A, B, C, B, D, E, F, H, I, G, M, O
found.
key
P3: A, B, C B, D, E, F, H, J, K, E, F, H, J, K, E, G, N, O
element
key
Page
2013-14
Valu
e of
n
0
array
key
elemen
ts
-5
Expected Actual
Statu
Output
Outpu
s
t
key
not
found
2,3,5,6,7 5
Key
found
at
1,2,5
key
not
found
1,2,5
key
not
found
1,2,4,6,7 2
4,5,7,8,9 8
Key
found
at
key
found
at
Page 73
2013-14
8.6 SNAPSHOTS:
1. Snapshot to check successful search and not found key element.
3.
Snapshot to check successful search and not found key
element.
Page 74
2013-14
8.7 REFERENCES:
1. Requirement Specification
2. Assumptions
Page
2013-14
of
Page
2013-14
Page
2013-14
Page
2013-14
getch();
return 0;
}
9.4 TESTING
Program Graph for partition:
50
51
52
53
54
56
57
58
59
60
61
62
64
65
66
67
68
Page
2013-14
DD Path Graph:
A
B
C
D
E
Program
Graph
50,51,52,53
54
56
57,58,59,60,61,
62
64,65,66,67,68
Cyclomatic complixity
No. of edges =6
No. of
nodes=5 en+2
6-5+2 =3
No. of predicate nodes +1 (i.e., node B and node C)
2+1=3
No. of region + 1
R1 and R2 are two regions
2+1=3
According to cyclomatic complexity 3 basis path exists. They are;
Department of ISE, DSCE-Bangalore
80
Page
2013-14
P1: A, B, E
P2: A, B, C, D,
B, E P3: A, B,
C, B, E
4.2 Deriving test cases using basis
path testing: Test Cases
Test
TC ID
Case
Descripti
1
Testing for
path P1
2
Testing
for path
P2
3
Testing
for path
Expected
Array
output Value
elemen
Array
of i
ts
5
5
0
5, 4, 6,
2,
7 4, 6,
5,
7,
5
5, 4, 6,
2,
7 4, 6,
5,
7,
5
Actua
l
outpu
Status
4
0
Page 81
2013-14
28
29
31
30
32
33
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
Page
2013-14
DD Path Graph
T
C
R3
D
T
E
R1
F
F
F
R2
T
G
CYCLOMATIC COMPLEXITY
No. of nodes = 8
No. of nodes
=10 e-n+2
10-8+2 =4
No. of predicate nodes + 1
3+1=4 (i.e., node B,
D & F) No. of
regions+1
Department of ISE, DSCE-Bangalore
83
Page
2013-14
Test
Case
Descripti
Testing
for
path
1
Testing
for
path
2
Testing
for
path
3
Array
elemen
5,ts7, 4, 2,
1,
3 4, 8, 2,
5,
7
5, 4, 6, 7,
3
Expect
ed
2, output
1, 3, 5,
7,
4 4, 2, 7,
5,
8
3, 4, 6, 7,
5
Actua
l
outpu
Status
9.5 EXECUTION
Compile the program and enter inputs Test above
table array elements for test cases.
Page 84
2013-14
9.6 SNAPSHOTS:
1. Snapshot of quick sort sorted elements are displayed, when the
n=6
Page 85
2013-14
9.7 REFERENCES:
1. Requirement Specification
2. Assumptions
Page 86
2013-14
10. Design, develop, code and run the program in any suitable
language to implement an
absoluteletter
grading
procedure, making
suitable
assumptions.
Determine the basis paths and using them derive different test
cases, execute these test cases and discuss the test results.
10.1 REQUIREMENTS:
R1: The system should accept marks of 6 subjects, each marks
in the range 1 to 100.
i.e., for example,
1<=marks<=100
1<=kannada<=100
1<=maths<=100 etc.
R2: If R1 is satisfied compyter average of marks scored and
percentage of the same and depending on percentage display the
grade.
10.2 DESIGN:
We use the total percentage of marks to grade the student marks.
<35 && >0 of percentage make it as
FAIL avmar<=40 && avmar>35 make it
as Grade C avmar<=50 && avmar>40
make it as Grade C+ avmar<=60 &&
avmar>50 make it as Grade B
avmar<=70 && avmar>60 make it as
Grade B+ avmar<=80 && avmar>70
make it as Grade A avmar<=100 &&
avmar>80 make it as Grade A+
10.3 PROGRAM CODE:
#include<stdio.h>
main()
{
float kan,eng,hindi,maths,science, sst,avmar;
printf("Letter Grading\n");
printf("SSLC Marks Grading\n");
printf("Enter the marks for
Kannada:"); scanf("%f",&kan);
printf("enter the marks for English:");
Department of ISE, DSCE-Bangalore
Page
87
2013-14
scanf("%f",&eng);
printf("enter the marks for Hindi:");
scanf("%f",&hindi);
printf("enter the marks for Maths");
scanf("%f",&maths);
printf("enter the marks for Science:");
scanf("%f",&science);
printf("enter the marks for Social
Science:"); scanf("%f",&sst);
avmar=(kan+eng+hindi+maths+science+
sst)/6.25; printf("the average marks are=
%f\n",avmar); if((avmar<35)&&(avmar>0))
printf("fail"); else
if((avmar<=40)&&(avmar
>35)) printf("Grade C");
else
if((avmar<=50)&&(avmar
>40)) printf("Grade C+");
else
if((avmar<=60)&&(avmar
>50)) printf("Grade B");
else
if((avmar<=70)&&(avmar
>60)) printf("Grade B+");
else
if((avmar<=80)&&(avmar
>70)) printf("Grade A");
else
if((avmar<=100)&&(avmar>80))
printf("Grade A+");
}
Page
2013-14
10.4 TESTING
PROGRAM GRAPH:
1
14
15
16
17
18
19
10
11
12
20
21
22
T
24
23
F
T
25
F
27
F
26
T
T
30
29
F
T
31
36
32
T
33
35
28
34
37
Page 89
13
Using the
DD path
Names
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
2013-14
CYCLOMATIC
COMPLEXITY
No. of nodes = 18
No. of edges =
24 e-n+2
24-18+2=8
A
T
B
F
C
T
D
T
F
R1
G
R2
H
I
F
J
F
R7
K
L
R3
R4
M
R5
O
R6
Page
2013-14
Status
Page 91
2013-14
SST=50
Avg=47.5
K=55
E=58
H=60
M=56
S=57
SST=60
Avg=57.6
6
K=65
E=65
H=65
M=65
S=65
SST=65
Avg=65.0
K=75
E=72
H=78
M=75
S=80
SST=80
Avg=76.6
K=85
E=90
H=80
M=95
S=85
SST=85
Avg=86.6
6
Grade B
Grade
B+
Grade A
Grade
A+
10.5 EXECUTION
Compile the program and enter inputs for subject marks, then it
will display the Total percentage, depending on the percentage it
will shows the Grade and
test the test cases for above table.
Page 92
2013-14
10.6 SNAPSHOTS:
1. Snapshot to Show Fail and Grade C
Page 93
4.
2013-14
Page 94
2013-14
10.7 REFERENCES:
1. Requirement Specification
2. Assumptions
Page
2013-14
11. Design, develop, code and run the program in any suitable
language to implement the NextDate function. Analyze it from the
perspective of boundary value testing, derive different test cases,
execute these test cases and discuss the test results.
11.1
REQUIREMENT
SPECIFICATION
Problem Definition: "Next Date" is a function consisting of
three variables like: month, date and year. It returns the date of
next day as output. It reads current
date
as
input
date.
The
are
constraints
C1: 1 month 12
C2: 1 day 31
C3: 1812 year 2012.
Page
2013-14
if
DD=30
do
STEP8: if MM is 12
STEP9: if DD<31 then STEP4 else STEP10
STEP10:
tomorrowday=1,
tommorowmonth=1,
tommorowyear=YYYY+1; goto STEP18
STEP11: if MM is 2
STEP12: if DD<28 do STEP4 else do STEP13
STEP13: if DD=28 & YYYY is a leap do STEP14 else STEP15
STEP14: tommorowday=29 goto STEP18
STEP15: tommorowday=1, tomorrowmonth=3, goto
STEP18; STEP16: if DD=29 then do STEP15 else
STEP17
STEP17: output(Cannot have feb, DD); STEP19
STEP18: output(tomorrowday, tomorrowmonth,
tomorrowyear); STEP19: exit
11.3 PROGRAM CODE:
#include<stdio.h>
#include<conio.h>
main( )
{
Department of ISE, DSCE-Bangalore
97
Page
2013-14
int
month[12]={31,28,31,30,31,30,31,31,30,3
1,30,31}; int d,m,y,nd,nm,ny,ndays;
clrscr( );
printf("enter the
date,month,year"); scanf("%d
%d%d",&d,&m,&y);
ndays=month[m-1];
if(y<=1812 && y>2012)
{
printf("Invalid Input Year");
exit(0);
}
if(d<=0 || d>ndays)
{
printf("Invalid Input Day");
exit(0);
}
if(m<1 && m>12)
{
printf("Invalid Input Month");
exit(0);
}
if(m==2)
{
if(y%100==0)
{
if(y%400==0)
ndays=29;
}
els
e
if(y%4==0)
ndays=29;
Department of ISE, DSCE-Bangalore
98
Page
2013-14
}
nd=d+
1;
nm=m;
ny=y;
if(nd>ndays)
{
nd=1;
nm++;
}
if(nm>12)
{
nm=1;
ny++;
}
printf("\n Given date is %d:%d:%d",d,m,y);
printf("\n Next days date is %d:%d:
%d",nd,nm,ny); getch( );
}
11.4 TESTING
Technique used: Boundary value analysis
Boundary value analysis testing technique is used to
identify errors at boundaries rather than finding those exist in
center of input domain.
Boundary value analysis is a next part of Equivalence
partitioning for designing test cases where test cases are
selected at the edges of the equivalence classes.
BVA: Procedure
5. Partition the input domain using unidimensional partitioning.
This leads to as many partitions as there are input variables.
Alternately, a single partition
Page
Software Testing
Laboratory
2013-14
Page
100
Test
design
2013-14
Case
The Next Date program takes date as input and checks it for
validity. If it is valid, it returns the next date as its output. Here
we have three inputs for the program, hence n = 3.
Since BVA yields (4n + 1) test cases according to single
fault assumption theory, hence we can say that the total number
of test cases will be (4*3+1)
=12+1=
13.
The boundary value test cases can be generated by using
following constraints
C1: 1 MM
12
C2: 1 DD
31
C3: 1812 YYYY
2012.
Here from these constraints we can extract the test cases using
the values of MM, DD, and YYYY. The following equivalence
classes can be generated for each variable.
Equivalence
classes
for MM:
E1: Values less than
1. E2: Values in the
range.
E3:
Values
greater
than 12.
Equivalence
classes
for DD:
E4: Values less than
1. E5: Values in the
range.
E6:
Values
greater
than 31.
Equivalence classes for
YYYY:
E7: Values less than
1812. E8: Values in
the range.
E9: Values greater than
2012.
From the above equivalence classes we can derive the following
test cases using boundary value analysis approach.
Page
2013-14
TC
Id
Test
Input Data
Case
Testing
Invalid
for
months
with
character
is
Testing for
Invalid
Day with
characterfor
is
Testing
Invalid
Year
with
characterfor
is
Testing
Invalid
Day,
dayfor
with 00
Testing
Valid
input
changing
the
day
within
the
Testing
for Valid
Aa
15
1900
Invalid
Month
Input
06
Dd 1901
Invalid
Day
Input
06
15
196y
Invalid
Year
Input
03
00
2000
03
30
2000
Invalid Input
Day
03/31/2000
03
02
2000
03/03/2000
03
32
2000
00
15
2000
11
15
2000
Invalid Input
Day
Invalid Input
Month
11/16/2000
02
15
2000
02/16/2000
13
15
2000
Invalid
Month
4
5
7
8
9
10
11
input
changing
the day within
the month.
Testing for
Invalid
Day,
dayfor
with 32
Testing
Invalid
Day,
month
Testing
for with
Valid
input
changing
the day
within
the month.
MM=11
Testing
for
Valid
input
changing
the day
within
the month.
MM=02
Testing
for
Invalid
Month, month
Expected
MM DD YYYY Output
Actual
Output
Status
Input
Page 102
12
13
14
15
13
Testing for
03
Invalid year,
year
should
Testing
for Valid 03
input
changing
the day within
the month.
MM=03
DD=15
Testing for Valid 03
input
changing
the day within
the month.
MM=03
DD=15 for
Testing
03
Invalid year,
year
should
Table-1: Test
2013-14
15
1811
Invalid
Year
Input
15
2011
03/16/2011
15
1813
03/16/1813
15
2013
Invalid
Year
Input
This is how we can apply BA technique to create test cases for our
Next Date
Problem.
11.5 EXECUTIONS
Execute the program and test the test cases in Table-1 against
program and complete the table with for Actual output column
and Status column
Test Report:
1.
2.
3.
4.
No
No
No
No
of
of
of
of
TCs Executed:
Defects Raised:
TCs Pass:
TCs Failed:
Page 103
2013-14
11.6 SNAPSHOTS:
1. Snapshot for Invalid Input day and next date
Page
2013-14
3. Valid Output.
11.7 REFERENCES:
1. Requirement Specification
2. Assumptions
Page
2013-14
12. Design, develop, code and run the program in any suitable
language to implement the NextDate function. Analyze it
from
the
perspective
of equivalence class value testing,
derive different test cases, execute these test cases and discuss
the test results.
12.1 REQUIREMENT SPECIFICATION
Problem Definition: "Next Date" is a function consisting of
three variables like: month, date and year. It returns the date of
next day as output. It reads current date as input date.
The constraints are
C1: 1 month 12
C2: 1 day 31
C3: 1812 year 2012.
If any one condition out of C1, C2 or C3 fails, then this function
produces an output "value of month not in the range 1...12".
Since many combinations of dates can exist, hence we can simply
displays one message for this function: "Invalid Input Date".
A very common and popular problem occurs if the year is a leap
year. We have taken into consideration that there are 31 days in a
month. But what happens
if a month has 30 days or even 29 or 28 days ?
A year is called as a leap year if it is divisible by 4, unless it is a
century year. Century years are leap years only if they are
multiples of 400. So, 1992, 1996 and 2000 are leap years while
1900 is not a leap year.
Furthermore, in this Next Date problem we find examples of Zipf's
law also, which states that "80% of the activity occurs in 20%
of the space". Thus in this case also, much of the source-code of
Next Date function is devoted to the leap year considerations.
12.2 DESIGN
Department of ISE, DSCE-Bangalore
106
Page
2013-14
Algorithm
STEP 1: Input date in format DD.MM.YYYY
STEP2: if MM is 01, 03, 05,07,08,10 do STEP3 else STEP6
STEP3:if DD < 31 then do STEP4 else if DD=31 do STEP5 else
output(Invalid
Date);
STEP4: tomorrowday=DD+1 goto STEP18
STEP5: tomorrowday=1; tomorrowmonth=month + 1 goto STEP18
STEP6: if MM is 04, 06, 09, 11 do STEP7
STEP7: if DD<30 then do STEP4 else if DD=30 do STEP5 else
output(Invalid
Date);
STEP8: if MM is 12
STEP9: if DD<31 then STEP4 else STEP10
STEP10: tomorrowday=1, tommorowmonth=1,
tommorowyear=YYYY+1; goto
STEP18
STEP11: if MM is 2
STEP12: if DD<28 do STEP4 else do STEP13
STEP13: if DD=28 & YYYY is a leap do STEP14 else STEP15
STEP14: tommorowday=29 goto STEP18
STEP15: tommorowday=1, tomorrowmonth=3, goto
STEP18; STEP16: if DD=29 then do STEP15 else
STEP17
STEP17: output(Cannot have feb, DD); STEP19
STEP18: output(tomorrowday, tomorrowmonth,
tomorrowyear); STEP19: exit
Page
2013-14
Page
2013-14
if(y%400==0)
ndays=29;
}
els
e
if(y%4==0)
ndays=29;
}
nd=d+
1;
nm=m;
ny=y;
if(nd>ndays)
{
nd=1;
nm++;
}
if(nm>12)
{
nm=1;
ny++;
}
printf("\n Given date is %d:%d:%d",d,m,y);
printf("\n Next days date is %d:%d:
%d",nd,nm,ny); getch( );
}
12.4 TESTING
Technique used: Equivalence Class testing
Test selection using equivalence partitioning allows a tester to
subdivide the input domain into a relatively small number of
sub-domains, say N>1, as
shown.
Page
Software Testing
Laboratory
2013-14
Page
110
2013-14
>12
00
Case
First
Attempt
Department of ISE, DSCE-Bangalore
111
Page
2013-14
Test Case
Description
Testing
Valid
Input Data
MM DD
for 6
input
15
Expected
YYYY Output
1900
Actual
Output
Status
6/16/1900
changing
the
day within the
Table 1: Weak and Strong Normal
Page 112
2013-14
Input Data
Test
Expecte
Case
d
MM DD YYYY
Descriptio
Outpu
15
1900
6/16/1900
Testing
for 6
Valid
input
changing the
day
Testing within
for 6
Invalid
Day,
day
with
negative
number
is 6
Testing it for
Invalid
Day,
day
with
Out
of range
Testingi.e., for -1
Invalid
Month, month
with
negative
number
is 13
Testing it for
Invalid
month,
month
with
out of range
i.e.,
MM=13 for it 6
Testing
Year, year is
out of range
YYYY=1899, it
should
<=1812
-1
1900
32
1900
15
1900
Month not in
range
15
1900
Month not in
range
15
1899
Actual
Output
Status
Page 113
6
Testing for
Year,
year is out
of range
YYYY=2013, it
should
2013-14
15
2013
Table 2:Weak
Robust
Page 114
Input Data
Test
Expecte
Case
d
MM DD YYYY
Descriptio
Outpu
Testing for Month
is not in range
MM=-1 i.e.,in
Month not
negative
-1
15
1900
in range
number there is
not possible have
to be month
in
negative
Testing
for Day is
not in range DD=1 i.e., in negative
-1
15
1899
-1
i) Day not
in range
1900
ii) Month not
in range
-1
i) Day not
in range
1899
ii) Year not in
range
number there
is
not possible have
to
be for
Day Year
in
Testing
is
not
2013-14
in
range
YYYY=1899
Testing for
i.e.,
Day
and month is not
in range MM=-1,
DD=-1
i.e.,
in
negative
number there
is
not possible have
to be Day and
MonthTesting
in
i)
for
Day
is not in
range and Year is
not in range DD=1 i.e., in
negative
number there is
not possible have
to be Day
in
negative
number, and
ii) YYYY=1899, so
-1
Actual
Output
Status
Year not
in range
Page 115
i)
Testing
for
Month
is not in range
MM=1 and i.e., in
negative number
there
is
not
possible have to
be Day
in
negative
number, and
i)
Testing
for
Day is not
in
range DD=-1 i.e.,
in
negative
number there is
not possible have
to be Day
in
negative
number
ii)
Testing
for
Month
is not in range
MM=1 and i.e., in
negative number
there
is
not
possible have to
2013-14
-1
-1
15
i) Month not
in range
1899
ii) Year not
in range
-1
i) Day not
in range
ii) Month not
1899
in range
iii) Year not in
range
Page 116
2013-14
Second
Attempt
As said before the equivalence relation is vital in producing
useful test cases and more time must be spent on designing
it. If we focus more on the equivalence relation and consider
more greatly what must happen to an input date we might
produce the following equivalence classes:
M1 = {month: month has 30
days} M2 = {month: month
has 31 days} M3 = {month:
month is February}
Here month has been split up into 30 days (April, June,
September and November), 31 days (January, March, April, May,
July, August, October and December) and February.
D1 = {day: 1 day
28} D2 = {day:
day = 29}
D3 = {day: day
= 30}
D4 = {day: day
= 31}
Day has been split up into intervals to allow months to
have a different number of days; we also have the special case
of a leap year (February 29 days).
Y1 = {year: year =
2000}
Y2 = {year: year is a leap
year}
Y3 = {year: year is
common year}
Year has been split up into common years, leap years and the
special case the year 2000 so we can determine the date in the
month of February.
Here are the test cases for the new equivalence relation using the
four types of
Equivalence
Class
testing.
Weak Normal
Department of ISE, DSCE-Bangalore
117
Page
2013-14
TC
Id
Testing
for
all 6
Valid input changing
the day within the
month.
7
Testing for Valid
input
changing the day
within the
Testing
for month.
Leaf year, 2
i.e., MM=2 (Feb) the
input DD=30, there is
not possible date 30, in
leaf year only 28 and 29
will occur.
Testing for Impossible 6
Date, i.e., MM=6 (June)
the input DD=31, there
is only 30 days in the
month of June, So,
DD=31 is Impossible
Date.
Input Data
MM DD
Expected
YYYY Output
14
2000
6/15/2000
29
1996
7/30/1996
30
2002
Impossible date
31
2000
Impossible input
date
Actual
Output
Status
Page 118
2013-14
Strong Normal
TC ID
Test Case
Description
Input Data
MM DD
Expected
YYYY Output
SN1
14
2000
6/15/2000
SN2
14
1996
6/15/1996
SN3
14
2002
6/15/2002
SN4
29
2000
6/30/2000
SN5
29
1996
6/30/1996
SN6
29
2002
6/30/2002
30
2000
30
1996
30
2002
31
2000
31
1996
31
2002
13
SN13
14
2000
Invalid Input
Date
Invalid Input
Date
Invalid Input
Date
Invalid Input
Date
Invalid Input
Date
Invalid Input
Date
7/15/2000
14
SN14
14
1996
7/15/1996
15
SN15
14
2002
7/15/2002
16
SN16
29
2000
7/30/2000
17
SN17
29
1996
7/30/1996
18
SN18
29
2002
7/30/2002
19
SN19
30
2000
7/31/2000
8
9
10
11
12
SN7
SN8
SN9
SN10
SN11
SN12
Actual
Output
Status
Page 119
2013-14
20
SN20
30
1996
7/31/1996
21
SN21
30
2002
7/31/2002
22
SN22
31
2000
8/1/2000
23
SN23
31
1996
8/1/1996
24
SN25
31
2002
8/1/2002
25
SN24
14
2000
2/15/2000
26
SN26
14
1996
2/15/1996
27
SN27
14
2002
2/15/2002
29
2000
29
1996
Invalid Input
Date
3/1/1996
29
2002
30
2000
30
1996
30
2002
31
2000
31
1996
31
2002
28
29
30
31
32
33
34
35
36
SN28
SN29
SN30
SN31
SN32
SN33
SN34
SN35
SN36
Invalid Input
Date
Invalid Input
Date
Invalid Input
Date
Invalid Input
Date
Invalid Input
Date
Invalid Input
Date
Invalid Input
Date
Page 120
2013-14
12.5 EXECUTIONS
Execute the program and test the test cases in Table-1 against
program and complete the table with for Actual output column
and Status column
Test Report:
1. No of TCs Executed:
2. No of Defects Raised:
3. No of TCs Pass:
4. No of TCs Failed:
12.6 SNAPSHOTS:
1. Snapshot to show the nextdate for current date and invalid day
is entered
Page
2013-14
2. Invalid Input
12.7 REFERENCES:
1. Requirement Specification
2. Assumptions
Page
2013-14
Triangle.c
Page