18ISL66 - Software Testing Laboratory - Lab Manual
18ISL66 - Software Testing Laboratory - Lab Manual
18ISL66 - Software Testing Laboratory - Lab Manual
BELAGAVI
Compiled By:
2022-23
Disclaimer
The information contained in this document is the proprietary and exclusive property of Acharya
Institutes except as otherwise indicated. No part of this document, in whole or in part, may be reproduced,
stored, transmitted, or used for course material development purposes without the prior written
permission of Acharya Institutes.
The information contained in this document is subject to change without notice. The information in this
document is provided for informational purposes only.
Trademark
Edition: 2022 - 23
Document Owner
The primary contact for questions regarding this document is:
Part B
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. 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.
2. 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.
3. 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
4. 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
5. 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
6. 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.
7. 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, execute
the test cases and discuss the results.
8. Design, develop, code and run the program in any suitable language to solve the commission
problem. Analyze it from the perspective of decision table-based testing, derive different test cases,
execute these test cases and discuss the test results
9. 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.
10. Design, develop, code and run the program in any suitable language to implement the binary search
algorithm. Determine the basis paths and using them derive different test cases, execute these test
cases and discuss the test results.
12. Design, develop, code and run the program in any suitable language to implement an absolute letter
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.
#include<stdio.h>
int main()
{
int a,b,c;
char istriangle;
printf("enter 3 integers which are sides of triangle\n");
scanf("%d%d%d",&a,&b,&c);
printf("a=%d\t,b=%d\t,c=%d",a,b,c);
if (istriangle=='y')
if ((a==b) && (b==c))
printf("equilateral triangle\n");
else if ((a!=b) && (a!=c) && (b!=c))
printf("scalene triangle\n");
else
printf("isosceles triangle\n");
else
printf("Not a triangle\n");
return 0;
}
#include<stdio.h>
int main()
{
int a,b,c,c1,c2,c3;
char istriangle;
do
{
printf("\nenter 3 integers which are sides of triangle\n");
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("\nthe value of a=%d is not the range of permitted value",a);
if (!c2)
printf("\nthe value of b=%d is not the range of permitted value",b);
if (!c3)
printf("\nthe value of c=%d is not the range of permitted value",c);
} while(!(c1 && c2 && c3));
if (istriangle=='y')
if ((a==b) && (b==c))
printf("equilateral triangle\n");
else if ((a!=b) && (a!=c) && (b!=c))
printf("scalene triangle\n");
else
printf("isosceles triangle\n");
else
printf("Not a triangle\n");
return 0;
}
Input Data
Actual
Case Id Description Expected Output Status Comments
Output
a B c
Should display the message Equilateral
1 Enter the min value for a , b and c 1 1 1 Equilateral PASS a=b=c
triangle
Enter the min value for 2 items and Message should be displayed can't form a
2 1 1 2
min +1 for any one item1 triangle
Enter the min value for 2 items and Message should be displayed can't form a
3 1 2 1
min +1 for any one item1 triangle
Enter the min value for 2 items and Message should be displayed can't form a
4 2 1 1
min +1 for any one item1 triangle
Enter the normal value for 2 items Should display the message Isosceles
5 5 5 1
and 1 item is min value triangle
Enter the normal value for 2 items Should display the message Isosceles
6 5 1 5
and 1 item is min value triangle
Enter the normal value for 2 items Should display the message Isosceles
7 1 5 5
and 1 item is min value triangle
Should display the message Equilateral
8 Enter the normal Value for a, b and c 5 5 5
triangle
Enter the max value for 2 items and Should display the message Isosceles
13 10 9 10
max - 1 for any one item triangle
Enter the max value for 2 items and Should display the message Isosceles
14 9 10 10
max - 1 for any one item triangle
Should display the message Equilateral
15 Enter the max value for a, b and c 10 10 10
triangle
24 lsales = lprice*tlocks;
25 ssales=sprice*tstocks;
26 bsales=bprice*tbarrels;
27 sales=lsales+ssales+bsales;
28 printf("\nthe total sales=%f\n",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);
}
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("the commission is=%f\n",comm);
41 return 0;
42 }
/* Assumption price for lock=45.0, stock=30.0 and barrels=25.0 production limit could sell
in a month 70 locks,80 stocks and 90 barrels commission on sales = 10 % <= 1000 and 15 %
on 1000 to 1800 and 20 % on above 1800*/
#include<stdio.h>
int main()
{
int locks, stocks, barrels, tlocks, tstocks, tbarrels;
float lprice, 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 ");
else
{
temp=tstocks+stocks;
if(temp>80)
printf("new total stocks =%d not in the range 1..80 so old ",temp);
else
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(tlocks>0&&tstocks>0&&tbarrels>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)
{
comm =0.10*1000;
comm=comm+0.15*(sales-1000);
}
else
comm=0.10*sales;
CHECKING BOUNDARY VALUE FOR LOCKS, STOCKS AND BARRELS AND COMMISSION
Commission Problem Output Boundary Value Analysis Cases
Input Data Expected Output Actual output
Case Status
Description Total Total Total Comm- Comm
Id Sales Sales Comment
Locks Stocks Barrels ission -ission
1 Enter the min value for locks, stocks and barrels 1 1 1 100 10 output minimum
2 1 1 2 125 12.5 output minimum +
Enter the min value for 2 items and min +1 for
3 1 2 1 130 13 output minimum +
any one item
4 2 1 1 145 14.5 output minimum +
Enter the value sales approximately mid value
5 between 100 to 1000 5 5 5 500 50 Midpoint
6 10 10 9 975 97.5 Border point -
Enter the values to calculate the commission for
7 10 9 10 970 97 Border point -
sales nearly less than 1000
8 9 10 10 955 95.5 Border point -
9 Enter the values sales exactly equal to 1000 10 10 10 1000 100 Border point
10 10 10 11 1025 103.75 Border point +
Enter the values to calculate the commission for
11 10 11 10 1030 104.5 Border point +
sales nearly greater than 1000
12 11 10 10 1045 106.75 Border point +
Enter the value sales approximately mid value
13 between 1000 to 1800 14 14 14 1400 160 Midpoint
14 Enter the values to calculate the commission for 18 18 17 1775 216.25 Border point -
15 sales nearly less than 1800 18 17 18 1770 215.5 Border point -
16 17 18 18 1755 213.25 Border point -
17 Enter the values sales exactly equal to 1800 18 18 18 1800 220 Border point
18 18 18 19 1825 225 Border point +
Enter the values to calculate the commission for
19 18 19 18 1830 226 Border point +
sales nearly greater than 1800
20 19 18 18 1845 229 Border point +
Enter the values normal value for lock, stock and
21 barrel 48 48 48 4800 820 Midpoint
22 70 80 89 7775 1415 Output maximum -
Enter the max value for 2 items and max - 1 for
23 any one item 70 79 90 7770 1414 Output maximum -
24 69 80 90 7755 1411 Output maximum -
25 Enter the max value for locks, stocks and barrels 70 80 90 7800 1420 Output maximum
Valid Classes
L1 ={LOCKS :1 <=LOCKS<=70}
L2 ={Locks=-1}(occurs if locks=-1 is used to control input iteration)
L3 ={stocks : 1<=stocks<=80}
L4= {barrels :1<=barrels<=90}
Invalid Classes
L3 ={locks: locks=0 OR locks<-1}
L4 ={locks: locks> 70}
S2 ={stocks : stocks<1}
S3 ={stocks : stocks >80}
B2 ={barrels : barrels <1}
B3 =barrels : barrels >90}
Commission Problem Output Equivalence Class Testing
( Weak & Strong Normal Equivalence Class )
Input Data Expected Output Actual output
Case Stat
Description Total Total Total Commiss Comment
Id Sales Commission Sales us
Locks Stocks Barrels ion
Enter the value within the range for
1 35 40 45 3900 640
lock, stocks and barrels
Weak Robustness Equivalence Class
Case Description Input Data Expected Output Actual output Status Comment
WR4 Enter the value less than or equal than 35 0 45 Value of stocks not in the range 1..80
0 for stocks and other valid inputs
Enter the value greater than 80 for
WR5 35 81 45 Value of stocks not in the range 1..80
stocks and other valid inputs
Enter the value less than or equal 0 for
WR6 35 40 0 Value of Barrels not in the range 1..90
barrels and other valid inputs
Enter the value greater than 90 for
WR7 35 40 91 Value of Barrels not in the range 1..90
barrels and other valid inputs
Precondition : Initial Value Total Locks= 0 , Total Stocks=0 and Total Barrels=0
Precondition Limit :Total locks, stocks and barrels should not exceed the limit 70,80 and 90 respectively
#include<stdio.h>
int binsrc(int x[],int low,int high,int key)
{
int mid;
while(low<=high)
{
mid=(low+high)/2;
if(key==x[mid])
return mid;
if(key<x[mid])
high=mid-1;
else
low=mid+1;
}
return -1;
}
int main()
{
int x[20],key,i,n,succ;
printf("Enter the n value");
scanf("%d",&n);
if(n>0)
{
printf("enter the elements in ascending order\n");
for(i=0;i<n;i++)
scanf("%d",&x[i]);
/*Design, develop, code and run the program in any suitable language to implement the
Quick-Sort Algorithm. Determine the basis paths and using them derive different test
cases, execute these test cases and discuss the test results.*/
#include<stdio.h>
void quick_sort(int a[100],int low,int high)
{
int i,j,temp,key;
if(low<high)
{
key=a[low];
i=low;
j=high;
temp=a[low];
a[low]=a[j];
a[j]=temp;
quick_sort(a,low,j-1);
quick_sort(a,j+1,high);
}
}
//Main Function
void main()
{
int i,n,a[100];
printf("Enter the value for n\n");
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
Software testing laboratory
Department of ISE
quick_sort(a,0,n-1);
printf("The sorted array is\n");
for(i=0;i<n;i++)
printf("%d\n",a[i]);
}
temp=a[low]; 15 K
a[low]=a[j]; 16 K
a[j]=temp; 17 K
quick_sort(a,low,j-1); 18 L
quick_sort(a,j+1,high); 19 M
} 20
}
A Initialization
Low<high
B
F T
i < =j
C
T
F
N D Right Scan
J F
T
E F Left Scan
K T F
F
i<j
G H I
M T
Recursive Calls
Independent Paths– Quick Sort
P1: A-B-N
P2: A-B-C-J-K-B
P3: A-B-C-J-K-M-B
P4: A-B-C-D-F-H-C
Independent Paths:
P5: A-B-C-D-F-H-I-C
P6: A-B-C-D-E-D-F-H
#Edges=18, #Nodes=13, #P=1
P7: A-B-C-D-F-G-F-H V(G)= E-N+2P = 18-13+2 = 7
Pre-Conditions/Issues:
Array has only one Element, Two Elements, Three Elements (6 Possibilities)
Array has Elements in ASC/DSC/Arbitrary( Any of the Permutations)
EX: 3 elements: 123, 132, 213, 231, 312, 321, 222,111,333
/* Design, develop, code and run the program in any suitable language to implement an
absolute letter 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 */
#include<stdio.h>
int main()
{
float per;
char grade;
scanf("%f",&per);
if(per>=90)
grade= 'A';
else if(per>=80 && per<90)
grade ='B';
else if(per>=70 && per<80)
grade ='C';
else if(per>=60 && per<70)
grade='D';
else grade='E';
switch(grade)
{
case 'A': printf("\nEXCELLENT"); break;
case 'B':printf("\nVery Good"); break;
case 'C' : printf("\nGood"); break;
case 'D': printf("\nAbove Average"); break;
case 'E': printf("\n Satisfactory"); break;
}
printf("\t The percentage = %f and grade is %c ",per,grade);
return 0;
}
Pre-Conditions/Issues:
Percentage Per is a positive Float Number
/* 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 and
equivalence class analysis. Derive different test cases, execute these test cases and
discuss the test results. */
#include<stdio.h>
int check(int day,int month)
{
if((month==4||month==6||month==9 ||month==11) && day==31)
return 1;
else
return 0;
}
int isleap(int year)
{
if((year%4==0 && year%100!=0) || year%400==0)
return 1;
else
return 0;
}
int main()
{
int day,month,year,tomm_day,tomm_month,tomm_year;
char flag;
do
{
flag='y';
printf("\nenter the today's date in the form of dd mm yyyy\n");
scanf("%d%d%d",&day,&month,&year);
tomm_month=month;
tomm_year= year;
if(day<1 || day>31)
{
printf("value of day, not in the range 1...31\n");
flag='n';
}
if(month<1 || month>12)
{
printf("value of month, not in the range 1. ... 12\n");
flag='n';
}
else if(check(day,month))
{
printf("value of day, not in the range day<=30");
flag='n';
}
if(year<=1812 || year>2013)
{
switch (month)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:if(day<31)
tomm_day=day+1;
else
{
tomm_day=1;
tomm_month=month+1;
}
break;
case 4:
case 6:
case 9:
case 11: if(day<30)
tomm_day=day+1;
else
{
tomm_day=1;
tomm_month=month+1;
}
break;
1 Enter the min value month, day and year 1 1 1812 1 2 1812
Enter the min+1 value for year and min
2 for month and day 1 1 1813 1 2 1813
Enter the normal value for year and min
3 for month and day 1 1 1912 1 2 1912
Enter the max -1 value for year and min
4 for month and day 1 1 2012 1 2 2012
Enter the max value for year and min for
5 month and day 1 1 2013 1 2 2013
Enter the min+1 value of day and min for
6 month and year 1 2 1812 1 3 1812
Invalid cases
M2 = {month : month < 1}
M3 = {month : month > 12}
D2 = {day : day < 1}
D3 = {day : day > 31}
Y2 = {year : year < 1812}
Y3 = {year : year > 2013}
Case Id Description Input Data Expected Output Actual Output Status Comment
day month year day Month year day month year
1 Enter the D1, M1 and Y1 valid 31 12 1811 Should display the
cases message value of the
year in range
1812..2013
2 Enter the D1, M1 and Y2 valid 31 12 2012 1 1 2013
cases
3 Enter the D1, M1 and Y3 valid 31 12 2013 Should display the
cases message Next is out of
boundary 2013
Validation, on the other hand, entails the real testing and it is done after completing the
verification.
Errors in programming
Lack of communication or no communications at all
Requirements changes
Time pressures
Test boundary conditions on, below and above the edges of input and output equivalence
classes. For instance, let say a bank application where you can withdraw maximum Rs.20,000
and a minimum of Rs.100, so in boundary value testing we test only the exact boundaries,
rather than hitting in the middle. That means we test above the maximum limit and below the
minimum limit.
What is failure?
What is V-Model?
A software development model that illustrates how testing activities integrate with software
development phases
Test coverage measures in some specific way the amount of testing performed by a set of
tests (derived in some other way, e.g., using specification-based techniques).
Component testing, also known as unit, module, and program testing, searches for defects in
and verifies the functioning of software (e.g., modules, programs, objects, classes, etc.) that
are separately testable.
What is a Defect?
The variation between the actual results and expected results is known as a defect. If a
developer finds an issue and corrects it by himself in the development phase then it’s called a
defect.
What is a Bug?
If testers find any mismatch in the application/system in testing phase then they call it as Bug
What is an Error?
We can’t compile or run a program due to a coding mistake in a program. If a developer
unable to successfully compile or run a program then they call it as an error.
What is a Failure?