Sunteți pe pagina 1din 41

SOFTWARE TESTING LABORATORY [16MCA48]

INDEX:
Sl. No. LIST OF PROGRAMS Page. No. Date
1. Design and develop a program in a language 1-7
of your choice to solve the triangle problem
defined as follows: Accept three integers
which are supposed to be the three sides of a
triangle and determine if the three values
represent an equilateral triangle, isosceles
triangle, scalene triangle, or they do not form
a triangle at all. Derive test cases for your
program based on decision-table approach,
the test cases and discuss the results.
2. Design and develop a program in a language 8-12
of your choice to solve the triangle problem
defined as follows: Accept three integers
which are supposed to be the three sides of a
triangle and determine if the three values
represent an equilateral triangle, isosceles
triangle, scalene triangle, or they do not form
a triangle at all. Assume that the upper limit
for the size of any side is 10. Derive test
cases for your program based on boundary-
value analysis, execute the test cases and
discuss the results.
3. Design and develop a program in a language 13-18
of your choice to solve the triangle problem
defined as follows: Accept three integers
which are supposed to be the three sides of a
triangle and determine if the three values
represent an equilateral triangle, isosceles
triangle, scalene triangle, or they do not form
a triangle at all. Assume that the upper limit
for the size of any side is 10. Derive test cases
for your program based on equivalence class
partitioning, execute the test cases and discuss
the results.

[1MV16MCA28] Page 1
SOFTWARE TESTING LABORATORY [16MCA48]

4. Design, develop, code and run the program in 19-25


any suitable language to solve the
commission problem. Analyze it from the
perspective of dataflow testing, derive
different test cases, execute these test cases
and discuss the test results.
5. Design, develop, code and run the program in 26-31
any suitable language to solve the
commission problem. Analyze it from the
perspective of boundary value testing, derive
different test cases, execute these test cases
and discuss the test results.

6. Design, develop, code and run the program 32-41


in any suitable language to solve the
commissionproblem. Analyze it from the
perspective of equivalence class testing,
derive different test cases, execute these test
cases and discuss the test results.

[1MV16MCA28] Page 2
SOFTWARE TESTING LABORATORY [16MCA48]

1. Design and develop a program in a language of your choice to solve the


triangle problem defined as follows: Accept three integers which are
supposed to be the three sides of a triangle and determine if the three
values represent an equilateral triangle, isosceles triangle, scalene
triangle, or they do not form a triangle at all. Derive test cases for your
program based on decision-table approach, the test cases and discuss the
results.

#include<stdio.h>
#include<conio.h>
void main()
{
inta,b,c;
clrscr();
printf("\nEnter the values for a,b and c:");
scanf("%d %d %d",&a,&b,&c);
if((a<=(b+c))&&(b<=(c+a))&&(c<=(a+b)))
{
printf("\nThis forms a triangle");
if((a==b)&&(a==c))
{
printf("\nThis is a Equilateral Triangle");
}
else if((a!=b) && (b!=c) && (c!=a))
{
printf("\nThis is a Scalene Triangle");
}
else
{
printf("\nThis is a Isosceles Triangle");
}

}
else
{
printf("\nThis will not form a triangle");
}
getch();
}

[1MV16MCA28] Page 3
SOFTWARE TESTING LABORATORY [16MCA48]

OUTPUT:
Test Case Name : Decision table for triangle problem
Program Number: 1
Test Data : Enter the 3 Integer Value (a,b and c)
Pre-condition : a < b + c, b < a + c and c < a +b
Brief Description : Check whether given value for a equilateral, isosceles ,
scalene
triangle or can’t form a triangle

[1MV16MCA28] Page 4
RULES R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11

C1 : a < b + c F T T T T T T T T T T

[1MV16MCA28]
C2 : b < a + c - F T T T T T T T T T

C3 : c < a +b - - F T T T T T T T T

C4 : a = b - - - T T T T F F F F
Conditions
C5 : a = c - - - T T F F T T F F
SOFTWARE TESTING LABORATORY

C6 : b = c - - - T F T F T F T F

A1: Not a triangle X X X


Input data Decision Table

A2 : Scalene Triangle X

A3 : Isosceles Triangle X X X
Actions

A4 : Equilateral Triangle X

A5 : Impossible X X X
[16MCA48]

Page 5
Case Description Input Data Expected Actual Output Status Comments
ID Output
A B C

1 Enter the value of a,b 20 5 5 Message should This will not PASS Satisfied
and c such that a is be displayed form a triangle

[1MV16MCA28]
not less than sum of can’t form a
two sides triangle
2 Enter the value a,b, 3 15 11 Message should This will not PASS Satisfied
and c such that b is be displayed form a triangle
not less than sum of can’t form a
two sides and a is less triangle
than sum of other two
sides
3 Enter the value a,b, 4 5 20 Message should This will not PASS Satisfied
SOFTWARE TESTING LABORATORY

and c such that b is be displayed form a triangle


not less than sum of can’t form a
two sides and b is triangle
less than sum of other
two sides
4 Enter the value a,b 5 5 5 Should display This is a PASS Satisfied
and c satisfying the message Equilateral
precondition and a=b, Equilateral Triangle
b=c and c=a Triangle
Triangle Problem-Decision Table Test cases for input data

5 Enter the value a,b 10 10 9 Should display This is a PASS Satisfied


and c satisfying the message Isosceles
[16MCA48]

Page 6
precondition and a=b, Isosceles Triangle
b!=c Triangle
6 Enter the value a,b 5 6 7 Should display a This is a PASS Satisfied
and c satisfying message Scalene
precondition and Scalene Triangle

[1MV16MCA28]
a!=b, b!=c and c!=a Triangle
SOFTWARE TESTING LABORATORY

RESULT: The program was succesfully executed and output verified.


[16MCA48]

Page 7
SOFTWARE TESTING LABORATORY [16MCA48]

2. Design and develop a program in a language of your choice to solve the


triangle problem defined as follows: Accept three integers which are
supposed to be the three sides of a triangle and determine if the three
values represent an equilateral triangle, isosceles triangle, scalene
triangle, or they do not form a triangle at all. Assume that the upper
limit for the size of any side is 10. Derive test cases for your program
based on boundary-value analysis, execute the test cases and discuss the
results.
#include<stdio.h>
#include<conio.h>
void main()
{
inta,b,c;
clrscr();
printf("\nEnter the values for a,b and c:");
scanf("%d %d %d",&a,&b,&c);
if((a<=(b+c))&&(b<=(c+a))&&(c<=(a+b)))
{
printf("\nThis forms a triangle");
if((a==b)&&(a==c))
{
printf("\nThis is a Equilateral Triangle");
}
else if((a!=b) && (b!=c) && (c!=a))
{
printf("\nThis is a Scalene Triangle");
}
else
{
printf("\nThis is a Isosceles Triangle");
}

}
else
{
printf("\nThis will not form a triangle");
}
getch();
}

[1MV16MCA28] Page 8
SOFTWARE TESTING LABORATORY [16MCA48]

OUTPUT:

Test Case Name : Boundary Value Analysis for triangle


Problem Experiment Number : 2
Test Data : Enter 3 Integer Values( a, b and c)
Pre-Condition : 1<=a<=10, 1<=b<=10 and 1<=c<=10 and a < b + c, b < a + c
and
c< a+b
Brief Description : Check whether given values for a Equilateral, Isosceles,
Scalene
triangle or can’t form a triangle

[1MV16MCA28] Page 9
Case Description Input Data Expected Output Actual Output Status Comments
ID
A B C

[1MV16MCA28]
1 Enter the min value 1 1 1 Should display This is a PASS Satisfied
for a, b and c the message Equilateral triangle
Equilateral
triangle
2 Enter the min value 1 1 2 Message should This will not form PASS Satisfied
for 2 items and be displayed a triangle
min+1 for any one can’t form a
item1 triangle
3 Enter the min value 1 2 1 Message should This will not form PASS Satisfied
SOFTWARE TESTING LABORATORY

for 2 items and be displayed a triangle


min+1 for any one can’t form a
item1 triangle
4 Enter the min value 2 1 1 Message should This will not form PASS Satisfied
for 2 items and be displayed a triangle
min+1 for any one can’t form a
item1 triangle
5 Enter the nominal 5 5 1 Should display This is a Isosceles PASS Satisfied
value for 2 items the message triangle
and 1 item is min Isosceles triangle
value
Triangle Problem –Boundary value Test Cases for input data

6 Enter the nominal 5 1 5 Should display This is a Isosceles PASS Satisfied


value for 2 items the message triangle
[16MCA48]

Page 10
and 1 item is min Isosceles triangle
value
7 Enter the 1 5 5 Should display This is a Isosceles PASS Satisfied
nominalvalue for 2 the message triangle
items and 1 item is Isosceles triangle
min value
8 Enter the nominal 5 5 5 Should display This is a PASS Satisfied

[1MV16MCA28]
value for a, b and c the message Equilateral triangle
Equilateral
triangle

9 Enter the nominal 5 5 10 Should display This will not form PASS Satisfied
value for 2 items the message can’t a triangle
and 1 item is max form a triangle
value
SOFTWARE TESTING LABORATORY

10 Enter the nominal 5 10 5 Should display This will not form PASS Satisfied
value for 2 items the message can’t a triangle
and 1 item is max form a triangle
value

11 Enter the nominal 10 5 5 Should display This will not form PASS Satisfied
value for 2 items the message can’t a triangle
and 1 item is max form a triangle
value
12 Enter the max value 10 10 9 Should display This is a Isosceles PASS Satisfied
for 2 items and 1 the message triangle
item is max -1 for Isosceles triangle
[16MCA48]

Page 11
any one item
13 Enter the max value for 10 9 10 Should display This is a PASS Satisfied
2 items and max-1 for the message Isosceles
any one item Isosceles triangle triangle

[1MV16MCA28]
14 Enter the max value for 9 10 10 Should display This is a PASS Satisfied
2 items and max-1 for the message Isosceles
any one item Isosceles triangle triangle
15 Enter the max value for 10 10 10 Should display This is a PASS Satisfied
a,b and c the message Equilateral
Equilateral triangle
triangle
SOFTWARE TESTING LABORATORY

RESULT: The program was succesfully executed and output verified.


[16MCA48]

Page 12
SOFTWARE TESTING LABORATORY [16MCA48]

3. Design and develop a program in a language of your choice to solve the


triangle problem defined as follows: Accept three integers which are
supposed to be the three sides of a triangle and determine if the three
values represent an equilateral triangle, isosceles triangle, scalene
triangle, or they do not form a triangle at all. Assume that the upper
limit for the size of any side is 10. Derive test cases for your program
based on equivalence class partitioning, execute the test cases and
discuss the results.

#include<stdio.h>
int main()
{
int a,b,c,c1,c2,c3;
char istriangle;
do
{
printf("\nEnter 3 integers which are sides of triangle");
scanf("%d%d%d",&a,&b,&c);
printf("\na=%d\tb=%d\tc=%d",a,b,c);
c1 = a>=1 && a<=10;
c2= b>=1 && b<=10;
c3= c>=1 && c<=10;
if (!c1)
printf("\nValue of a is not the range of permitted value");
if (!c2)
printf("\nValue of b is not the range of permitted value");
if (!c3)
printf("\nValue of c is not the range of permitted value");
} while(!(c1 && c2 && c3));

// to check is it a triangle or not

if( a<b+c&& b<a+c&& c<a+b )


istriangle='y';
else
istriangle ='n';
if (istriangle=='y')
if ((a==b) && (b==c))
printf("equilateral triangle\n");
else if ((a!=b) && (a!=c) && (b!=c))
[1MV16MCA28] Page 13
SOFTWARE TESTING LABORATORY [16MCA48]

printf("scalene triangle\n");
else
printf("isosceles triangle\n");
else
printf("Not a triangle\n");
return 0;
}

[1MV16MCA28] Page 14
SOFTWARE TESTING LABORATORY [16MCA48]

OUTPUT:
Test Case Name : Equivalence Class Analysis for triangle problem
Experiement Number : 3
Test Data : Enter 3 Integer Values( a, b and c)
Pre-Condition : 1<=a<=10, 1<=b<=10 and 1<=c<=10 and a < b + c, b < a + c
and
c< a+b
Brief Description : Check whether given values for a Equilateral, Isosceles,
Scalene
triangle or can’t form a triangle

[1MV16MCA28] Page 15
Case Description Input Data Expected Output Actual Output Status Comments
ID
A B C

[1MV16MCA28]
1 Enter the mid 5 5 5 Should display This is a PASS Satisfied
value for a, b the message Equilateral
and c Equilateral triangle
trianglle
2 Enter the min 2 2 3 Should display This is a PASS Satisfied
value for a, b the message Isosceles
and min+1 Isosceles triangle
for any one triangle
item
SOFTWARE TESTING LABORATORY

3 Enter the 3 4 5 Should display This is a PASS Satisfied


different the message Scalene triangle
values for a,b Scalaene
and c triangle
Weak Equivalence class Testing

4 Enter the min 4 1 2 Message should This will not PASS Satisfied
value for 1 be displayed form a triangle
item and any can’t form a
Triangle Problem –Equivalence class Testing

value for 2 triangle


items
[16MCA48]

Page 16
5 Enter one invlaid -1 5 5 Should display value of a is not PASS Satisfied
input and two valid value of a is not in the range of
value for a,b and c in the range of permitted values
permitted values

[1MV16MCA28]
6 Enter one invlaid 5 -1 5 Should display value of b is not PASS Satisfied
input and two valid value of b is not in the range of
value for a,b and c in the range of permitted values
permitted values
7 Enter one invlaid 5 5 -1 Should display value of c is not PASS Satisfied
input and two valid value of c is not in the range of
value for a,b and c in the range of permitted values
permitted values
8 Enter one invlaid 11 5 5 Should display value of a is not PASS Satisfied
SOFTWARE TESTING LABORATORY

input and two valid value of a is not in the range of


value for a,b and c in the range of permitted values
permitted values
9 Enter one invlaid 5 11 5 Should display value of b is not PASS Satisfied
input and two valid value of b is not in the range of
Weak Robust Equivalence Class testing

value for a,b and c in the range of permitted values


permitted values
10 Enter one invlaid 5 5 11 Should display value of c is not PASS Satisfied
input and two valid value of c is not in the range of
value for a,b and c in the range of permitted values
permitted values
[16MCA48]

Page 17
11 Enter one invalid -1 5 5 Should display value value of a is not PASS Satisfied
input and two valid of a is not in the in the range of
value for a,b and c range of permitted permitted values
values
12 Enter one invalid 5 -1 5 Should display value value of b is not PASS Satisfied

[1MV16MCA28]
input and two valid of b is not in the in the range of
value for a,b and c range of permitted permitted values
values
13 Enter one invalid 5 5 -1 Should display value value of c is not PASS Satisfied
input and two valid of a is not in the in the range of
value for a,b and c range of permitted permitted values
values
14 Enter two invalid -1 -1 5 Should display value value of a and b PASS Satisfied
inputs and one valid of a and b is not in is not in the
SOFTWARE TESTING LABORATORY

input for a,b and c the range of range of


permitted values permitted values
15 Enter two invalid 5 -1 -1 Should display value value of b and c PASS Satisfied
inputs and one valid of b and c is not in is not in the
input for a,b and c the range of range of
permitted values permitted values
16 Enter two invalid -1 5 -1 Should display value value of a and c PASS Satisfied
Strong Robust Equivalence class Testing

inputs and one valid of a and b is not in is not in the


input for a,b and c the range of range of

RESULT: The program was succesfully executed and output verified.


permitted values permitted values
17 Enter aall invalid -1 -1 -1 Should display value value of a, b and PASS Satisfied
inputs of a, b and c is not in c is not in the
[16MCA48]

Page 18
the range of range of
permitted values permitted values
SOFTWARE TESTING LABORATORY [16MCA48]

4. Design, develop, code and run the program in any suitable language to
solve the commission problem. Analyze it from the perspective of
dataflow testing, derive different test cases, execute these test cases and
discuss the test results.

2. #include<stdio.h>
3. int main()
4. {
5. int locks,stocks,barrels,tlocks,tstocks,tbarrels;
6. float lprice,sprice,bprice,lsales,ssales,bsales,sales,comm;
7. lprice=45.0;
8. sprice=30.0;
9. bprice=25.0;
10.tlocks=0;
11.tstocks=0;
12.tbarrels=0;
13.printf("\nEnter the number of locks and to exit the loop enter -1 for locks:");
scanf("%d",&locks);
14.while(locks!=-1) {
15.printf("\nEnter the number of Stocks and Barrels:");
scanf("%d %d",&stocks,&barrels);
16.tlocks=tlocks+locks;
17.tstocks=tstocks+stocks;
18.tbarrels=tbarrels+barrels;
19.printf("\nEnter the number of locks and to exit the loop enter -1 for locks:");
scanf("%d",&locks);
20.}
21.printf("\nTotal locks : %d",tlocks);
22.printf("\nTotal Stocks : %d",tstocks);
23.printf("\nTotal Barrels : %d",tbarrels);
24.lsales=lprice*tlocks;
25.ssales=sprice*tstocks;
26.bsales=bprice*tbarrels;
27.sales=lsales+ssales+bsales;
28.printf("\nThe total Sales : %f",sales);
29.if(sales>1800.0)
30.{
31.comm=0.10*1000.0;
32.comm=comm+0.15*800;
33.comm=comm+0.20*(sales-1800.0);
[1MV16MCA28] Page 19
SOFTWARE TESTING LABORATORY [16MCA48]

}
34.else if(sales>1000)
35.{
36.comm=0.10*1000;
37.comm=comm+0.15*(sales-1000);
}
38.else
39.comm=0.10*sales;
40.printf("\nThe commission is : %f",comm);
41.return 0;
42.}

[1MV16MCA28] Page 20
SOFTWARE TESTING LABORATORY [16MCA48]

OUTPUT:

Test Case Name : Data Flow Testing for Commission Program


Experiment Number : 4
Pre-Condition : Enter -1 for locks to exit from input loop
Brief Description : Enter the locks, stocks and barrels > 0

[1MV16MCA28] Page 21
SOFTWARE TESTING LABORATORY [16MCA48]

Define/Use nodes for variables in the Commission Problem


Variable Name Defined at node Used at node
lprice 7 24
sprice 8 25
bprice 9 26
tlocks 10,16 16,21,24
tstocks 11,17 17,22,25
tbarrels 12,18 18,23,26
locks 13,19 14,16
stocks 15 17
barrels 15 18
lsales 24 27
ssales 25 27
bsales 26 27
sales 27 28,29,33,34,37,39
comm 31,32,33,36,37,39 32,33,37,42

[1MV16MCA28] Page 22
Test Description Variable Du-paths Definition Comments
ID path Clear?

[1MV16MCA28]
1 Check for lock price (7,24) <7-8-9-10-11-12-13-14-15-16-17- YES Satisfied
variable DEF(lprice,7) 18-19-20-21-22-23-24>
and USE(lprice,24)
2 Check for stock price (8,25) <8-9-10-11-12-13-14-15-16-17-18- YES Satisfied
variable DEF(sprice,8) 19-20-21-22-23-24-25>
and USE(sprice,25)
3 Check for barrel price (9,26) <9-10-11-12-13-14-15-16-17-18- YES Satisfied
SOFTWARE TESTING LABORATORY

variable DEF(bprice,9) 19-20-21-22-23-24-25-26>


and USE(sprice,226)
(10,16) <10-11-12-13-14-15-16> YES Satisfied

(10,21) <10-11-12-13-14-15-16-17-18-19- NO Satisfied


Check for total locks 20-14-21>
variable (10,24) <10-11-12-13-14-15-16-17-18-19- NO Satisfied
DEF((tlocks,10) and 20-14-21-22-23-24>
DEF(tlocks,16)) and 3 (16,16) <16-16> YES Satisfied
Selected Define/Use paths for Commission Problem

4 usage (16,21) <16-17-18-19-14-21> NO Satisfied


node(USE(tlocks,16),U
[16MCA48]

Page 23
SE(tlocks,21),USE(tloc (16,24) <16-17-18-19-20-14-21-22-23-24> NO Satisfied
ks,24)
(11,17) <11,12,13,14,15,16,17> YES Satisfied

(11,22) <11-12-13-14-15-16-17-18- NO Satisfied

[1MV16MCA28]
19-20-21-14-21>

Check for total locks variable (11,25) <11-12-13-14-15-16-17-18- NO Satisfied


DEF((tlocks,10) and 19-20-21-14-21-22-23-24-
DEF(tlocks,16)) and 3 usage 25>
5 node(USE(tlocks,16),USE(tlocks, (17,17) <17,17> YES Satisfied
21),USE(tlocks,24) (17,22) <17-18-19-20-14-21-22> NO Satisfied

(17,25) <17-18-19-20-14-21-22-23- NO Satisfied


SOFTWARE TESTING LABORATORY

24-25>
(13,14) <13,14> YES Begin the
loop
(13,16) <13-14-15-16> YES Satisfied
Check for locks variable
(DEF(locks,13), DEF(locks,19) (19,14) <19-20-14> YES Satisfied
6
and USE(locks,14),USE(locks,16) (19,16) <19-20-14-15-16> YES Repeat
the loop
Check for stocks variable (15,17) <15-16-17> YES Satisfied
(DEF(stocks,15) and
7
SE(stocks,17)
[16MCA48]

Page 24
8 Check for sales DEF(sales,27) (27,28) <27-28> YES Satisfied

[1MV16MCA28]
and USE(sales,28),
USE(sales,29), USE(sales,33), (27,29) <27-28-29> YES Satisfied
USE(sales,34), USE(sales,37),
USE(sales,39) (27,33) <27-28-29-30-31-32- YES Satisfied
33>
(27,34) <27-28-29-34> YES Satisfied

(27,37) <27-28-29-34-35-36- YES Satisfied


SOFTWARE TESTING LABORATORY

37>
(27,39) <27-28-29-34-38-39> YES Satisfied

Check for commission ((31,32,33 <31-32-33-34> YES Satisfied


variable ),42)
DEF(comm,31,32,33), ((34,35),4 <34-35-42> YES Satisfied
9 DEF(comm,34,35) and 2)
DEF(comm,39) and ((39),42) <39-42> YES Satisfied
USE(comm,42)

RESULT: The program was succesfully executed and output verified.


[16MCA48]

Page 25
SOFTWARE TESTING LABORATORY [16MCA48]

5. Design, develop, code and run the program in any suitable language to
solve the commission problem. Analyze it from the perspective of
boundary value testing, derive different test cases, execute these test
cases and discuss the test results.

#include<stdio.h>
int main()
{
intlocks,stocks,barrels,tlocks,tstocks,tbarrels;
floatlprice,sprice,bprice,lsales,ssales,bsales,sales,comm;
lprice=45.0;
sprice=30.0;
bprice=25.0;
tlocks=0;
tstocks=0;
tbarrels=0;
printf("\nEnter the number of locks and to exit the loop enter -1 for
locks:");
scanf("%d",&locks);
while(locks!=-1)
{
printf("\nEnter the number of Stocks and Barrels:");
scanf("%d %d",&stocks,&barrels);
tlocks=tlocks+locks;
tstocks=tstocks+stocks;
tbarrels=tbarrels+barrels;
printf("\nEnter the number of locks and to exit the loop enter -1 for
locks:");
scanf("%d",&locks);
}
printf("\nTotal locks : %d",tlocks);
printf("\nTotal Stocks : %d",tstocks);
printf("\nTotal Barrels : %d",tbarrels);
lsales=lprice*tlocks;
ssales=sprice*tstocks;
bsales=bprice*tbarrels;
sales=lsales+ssales+bsales;
printf("\nThe total Sales : %f",sales);
if(sales>1800.0)

[1MV16MCA28] Page 26
SOFTWARE TESTING LABORATORY [16MCA48]

{
comm=0.10*1000.0;
comm=comm+0.15*800;
comm=comm+0.20*(sales-1800.0);
}
else if(sales>1000)
{
comm=0.10*1000;
comm=comm+0.15*(sales-1000);
}
else
comm=0.10*sales;
printf("\nThe commission is : %f",comm);
return 0;
}

[1MV16MCA28] Page 27
SOFTWARE TESTING LABORATORY [16MCA48]

OUTPUT:

Test Case Name : Boundary Value Analysis for Commission Problem


Experiment Number : 5
Test data : Price Rs. For lock=45.0, stock=30.0 and barrel=25.0
sales=total lock*lock price+total stock*stock price+total
barrel*barrel price
commission=10% up to sales 1000 Rs. , 15% of the next 800 Rs. And
20% on any sales excess of 1800
Pre – Condition : lock -1 to exit and 1<=lock<=70, 1<=stock<=80 and
1<=barrels<=90
Brief Description : The sales person had to sell at least one complete rifle per
month

[1MV16MCA28] Page 28
Input data Expected Actual Status Comment
Output Output
Case Description
ID Total Total Total Sales Com Sales Com

Cases
locks stock Barrels m. m.
1 Enter the min value 1 1s 1 100 10 100 10 PASS Output

[1MV16MCA28]
for locks, stocks and minimum
barrels
2 1 1 2 125 12.5 125 12.5 PASS

3 Enter the min value 1 2 1 130 13 130 13 PASS Output


for 2 items and minimum
4 min+1 for any one 2 1 1 145 14.5 145 14.5 PASS +
5 Enter theitem
value sales 5 5 5 500 50 500 50 PASS Midpoint
approx. mid value
SOFTWARE TESTING LABORATORY

6 between
Enter the100 to 1000
values to 10 10 9 975 97.5 975 97.5 PASS
calculate the
7 10 9 10 970 97 970 97 PASS Border
commission for sales
point
8 nearly less than 1000 9 10 10 955 95.5 955 95.5 PASS
-
9 Enter the values 10 10 10 1000 100 1000 100 PASS Border
sales exactly equal to point
1000
10 Enter the values to 10 10 11 1025 103. 1025 103. PASS Border
calculate the 75 75 point
Commission Problem Output for Boundary Value analysis

11 commission for sales 10 11 10 1030 104. 1030 104. PASS +


nearly greater than 5 5
[16MCA48]

Page 29
12 1000 11 10 10 1045 106. 1045 106. PASS
75 75
13 Enter the value sales approx. mid value 14 14 14 1400 160 1400 160 PASS Midpoint
between 1000 and 1800
14 18 18 17 1775 216 1775 216 PASS
.25 .25
15 Enter the values to calculate the

[1MV16MCA28]
18 17 18 1770 215 1770 215 PASS
commission for sales nearly less than
16 .5 .5 Border
1800
17 18 18 1755 213 1755 213 PASS point
.25 .25 -
17 Enter the values sales exactly equal to 18 18 18 1800 220 1800 220 PASS Border
1000 point
18 18 18 19 1825 225 1825 225 PASS
19 Enter the values to calculate the 18 19 18 1830 226 1830 226 PASS Border
SOFTWARE TESTING LABORATORY

commission for sales nearly greater than point


20 1800 19 18 18 1845 229 1845 229 PASS
+
21 Enter the values nominal value for lock, 48 48 48 4800 820 4800 820 PASS Midpoint
stock and barrel

22 70 80 89 7775 141 7775 141 PASS Output


5 5 maximum
Enter the max value for 2 items and max
23 70 79 90 7770 141 7770 141 PASS
-1 for any one item +
4 4
24 69 80 90 7755 141 7755 141 PASS
1 1
[16MCA48]

Page 30
25 Enter the max value for locks, stocks 70 80 90 7800 142 7800 142 PASS Output
and barrels 0 0 maximum
Case Input Data Expected Actual Status Comment
ID Output Output
Description
Total Total Total Sales Com Sales Com
locks stocks barrels m. m.

[1MV16MCA28]
Enter the random 11 10 8 995 99.5 995 99.5 PASS Border
values such that to point
calculate commission
-
1 for sales nearly less
than 1000
Enter the random 10 11 9 1005 100. 1005 100. PASS Border
values such that to 75 75 point
calculate commission
+
SOFTWARE TESTING LABORATORY

2 for sales nearly greater


than 1000
Enter the random 18 17 19 1795 219. 1795 219. PASS Border
values such that to 25 25 point
calculate commission
-
3 for sales nearly less
than 1800
Enter the random 19 19 17 1805 221 1805 221 PASS Border
values such that to

RESULT: The program was succesfully executed and output verified.


point
calculate commission
4 for sales nearly greater +
than 1800
[16MCA48]

Page 31
SOFTWARE TESTING LABORATORY [16MCA48]

6. Design, develop, code and run the program in any suitable language to
solve the commission problem. Analyze it from the perspective of
equivalence class testing, derive different test cases, execute these test
cases and discuss the test results.

#include<stdio.h>
int main()
{
int locks, stocks, barrels, tlocks, tstocks, tbarrels;
floatlprice, sprice, bprice, sales, comm;
int c1,c2,c3,temp;
lprice=45.0;
sprice=30.0;
bprice=25.0;
tlocks=0;
tstocks=0;
tbarrels=0;
printf("\nenter the number of locks and to exit the loop enter -1 for
locks\n");
scanf("%d",&locks);
while(locks!=-1)
{
c1=(locks<=0||locks>70);
printf("enter the number of stocks and barrels\n");
scanf("%d%d",&stocks,&barrels);
c2=(stocks<=0||stocks>80);
c3=(barrels<=0||barrels>90);
if(c1)
printf("value of locks not in the range 1..70 ");
else
{
temp=tlocks+locks;
if(temp>70)
printf("new total locks =%d not in the range 1..70 so
old ",temp);
else
tlocks=temp;
}
printf("total locks = %d\n",tlocks);

if(c2)
printf("value of stocks not in the range 1..80 ");

[1MV16MCA28] Page 32
SOFTWARE TESTING LABORATORY [16MCA48]

else
{

temp=tstocks+stocks;
if(temp>80)
printf("new total stocks =%d not in the range 1..80 so old
",temp);
else
tstocks=temp;
}
printf("total stocks=%d\n",tstocks);

if(c3)
printf("value of barrels not in the range 1..90 ");
else
{
temp=tbarrels+barrels;
if(temp>90)
printf("new total barrels =%d not in the range 1..90 so old
",temp);
else
tbarrels=temp;
}
printf("total barrel=%d",tbarrels);
printf("\nenter the number of locks and to exit the loop enter -1 for
locks\n");
scanf("%d",&locks);
}
printf("\ntotal locks = %d\ntotal stocks =%d\ntotal barrels
=%d\n",tlocks,tstocks,tbarrels);
sales = lprice*tlocks+sprice*tstocks+bprice*tbarrels;
printf("\nthe total sales=%f\n",sales);

if(sales > 0)
{
if(sales > 1800.0)
{
comm=0.10*1000.0;
comm=comm+0.15*800;
comm=comm+0.20*(sales-1800.0);
}
else if(sales > 1000)
{

[1MV16MCA28] Page 33
SOFTWARE TESTING LABORATORY [16MCA48]

comm =0.10*1000;
comm=comm+0.15*(sales-1000);
}
else
comm=0.10*sales;

printf("the commission is=%f\n",comm);


}
else
printf("there is no sales\n");
return 0;
}

[1MV16MCA28] Page 34
SOFTWARE TESTING LABORATORY [16MCA48]

OUTPUT:

Test Case Name : Boundary Value Analysis for Commission Problem


Experiment Number : 6
Test data : Price Rs. For lock=45.0, stock=30.0 and barrel=25.0
sales=total lock*lock price+total stock*stock price+total
barrel*barrel price
commission=10% up to sales 1000 Rs. , 15% of the next 800 Rs. And
20% on any sales excess of 1800
Pre – Condition : lock -1 to exit and 1<=lock<=70, 1<=stock<=80 and
1<=barrels<=90
Brief Description : The sales person had to sell at least one complete rifle per
month

[1MV16MCA28] Page 35
[1MV16MCA28]
Case Description Input Data Expected Actual Status Comment
ID Output Output
Total Total Total Sales Com Sales Com
locks stocks barrels m. m.
Enter the value 35 40 45 3900 640 3900 640 PASS Satisfied
SOFTWARE TESTING LABORATORY

within the
range for locks,
1 stocks and
barrels
Weak & Strong Normal Equivalence Class
Commission Problem Output Equivalence Class Testing
[16MCA48]

Page 36
Case Description Input Data Expected Output Actual Output Status Comment
ID
loc stoc barr
ks ks els

[1MV16MCA28]
WR1 Enter the value -1 40 45 Terminates the Terminates the PASS Satisfied
locks= -1 input loop and program
proceed to
calculate sales and
commission (if
sales>0)
WR2 Enter the value 0 40 45 Value of Locks not Value of locks is PASS Satisfied
less than -1 or in the range 1…70 not in the range
SOFTWARE TESTING LABORATORY

equal to zero for of 1…70


locks and other
valid inputs
WR3 Enter the value 71 40 45 Value of Locks not Value of locks is PASS Satisfied
greater than 70 in the range 1…70 not in the range
for locks and of 1…70
Weak Robustness Equivalence Class

other valid inputs


WR4 Enter the value 35 0 45 Value of Stocks Value of stocks is PASS Satisfied
less than or equal not in the range not in the range
to 0 for stocks 1…80 of 1…80
and other valid
inputs
[16MCA48]

Page 37
WR5 Enter the value 35 81 45 Value of Socks not Value of stocks PASS Satisfied
greater than 80 in the range 1…80 is not in the range
for stocks and of 1…80
other valid inputs

[1MV16MCA28]
WR6 Enter the value 35 40 0 Value of barrels Value of barrels PASS Satisfied
less than or equal not in the range not in the range
to zero for barrels 1…90 1…90
and other valid
inputs

WR7 Enter the value 35 40 91 Value of barrels Value of barrels PASS Satisfied
greater than 90 not in the range not in the range
SOFTWARE TESTING LABORATORY

for locks and 1…90 1…90


other valid inputs
[16MCA48]

Page 38
Case Description Input Data Expected Output Actual Output Status Comment
ID
loc stoc barr
ks ks els

[1MV16MCA28]
SR1 Enter the value -2 40 45 Value of Locks not Value of Locks PASS Satisfied
less than -1 for in the range 1…70 not in the range
locks and other 1…70
valid inputs
SR2 Enter the value 35 -1 45 Value of Socks not Value of Socks PASS Satisfied
less than or equal in the range 1…80 not in the range
to zero for stocks 1…80
SOFTWARE TESTING LABORATORY

and other valid


inputs
SR3 Enter the value 35 40 -2 Value of barrels Value of barrels PASS Satisfied
less than or equal not in the range not in the range
to zero for barrels 1…90 1…90
and other valid
Strong Robustness Equivalence Class

inputs
SR4 Enter the value -2 -1 45 Value of Locks not Value of Locks PASS Satisfied
less than or equal in the range 1…70 not in the range
to zero for locks 1…70
and stocks and Value of Stocks Value of Stocks
other valid input not in the range not in the range
[16MCA48]

Page 39
1…80 1…80
SR5 Enter the value -2 40 -1 Value of Locks not Value of Locks not PASS Satisfied
less than or equal in the range 1…70 in the range 1…70
to zero for locks
and barrels and Value of barrels Value of barrels

[1MV16MCA28]
other valid input not in the range not in the range
1…90 1…90

SR6 Enter the value 35 40 0 Value of barrels Value of barrels PASS Satisfied
less than or equal not in the range not in the range
to zero for barrels 1…90 1…90
and stocks and
other valid inputs Value of Stocks Value of Stocks
not in the range not in the range
SOFTWARE TESTING LABORATORY

1…80 1…80

SR7 Enter the value -2 -2 -2 Value of Locks not Value of Locks not PASS Satisfied
less than or equal in the range 1…70 in the range 1…70
to zero for locks ,
stocks and barrels
Value of Stocks Value of Stocks
not in the range not in the range
1…80 1…80

Value of barrels Value of barrels


not in the range not in the range
1…90 1…90
[16MCA48]

Page 40
Case Input Data Expected Actual Status Comment
ID Output Output
Description

Total Total Total Sales Com Sales Com

[1MV16MCA28]
locks stocks barrels m. m.

Enter the value for 5 5 5 500 50 500 50 PASS Satisfied


locks, stocks and
barrels where
OR1 0<sales<1000
SOFTWARE TESTING LABORATORY

Enter the value for 15 15 15 1500 175 1500 175 PASS Satisfied
locks, stocks and
barrels where
OR2 1000<sales<1800

Enter the value for 25 25 25 2500 360 2500 360 PASS Satisfied
locks, stocks and

RESULT: The program was succesfully executed and output verified.


barrels where
Some addition equivalence Boundary checking

OR3 sales<1800
[16MCA48]

Page 41

S-ar putea să vă placă și