Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

ST Lab Manual

Download as pdf or txt
Download as pdf or txt
You are on page 1of 70

Software testing laboratory 2019-20

EXPERIMENT No. 01: Triangle Problem-Boundary value Analysis

1.1 Objective 1.5 Test cases


1.2 Requirement specification 1.6 Execution
1.3 Design 1.7 Snapshots
1.4 Program Code 1.8 Pre-experiment & Post-experiment questions

1.1 OBJECTIVE
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.

1.2 REQUIREMENT SPECIFICATION


R1. The system should accept 3 positive integer numbers (a, b, c) which represents 3 sides of the
triangle.
R2. Based on the input should determine if a triangle can be formed or not.
R3. If the requirement R2 is satisfied then the system should determine the type of the triangle,
which can be
• Equilateral (i.e. all the three sides are equal)
• Isosceles (i.e Two sides are equal)
• Scalene (i.e All the three sides are unequal)
R4. Upper Limit for the size of any side is 10

1.3 DESIGN
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
Technique used: Boundary value analysis
1. 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.

Department of ISE, SCEM Page 1


Software testing laboratory 2019-20
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

0≤a≤10
0≤b≤10
0≤c≤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.
E5: Values in the range.
E6: Values greater than 10.

Equivalence classes for c:


E7: Values less than 1.
E8: Values in the range.
E9: Values greater than 10.

From the above equivalence classes we can derive the following test cases using boundary value
analysis approach.

1.4 PROGRAM CODE


#include<stdio.h>
#include<stdlib.h>
int main()
{
int a,b,c;
printf("Enter the three sides of traingle");
scanf("%d%d%d",&a,&b,&c);
if((a<1||a>10)||(b<1||b>10)||(c<1||c>10))
{
printf("Out of range values");
exit(0);
}
if((a<b+c)&&(b<a+c)&&(c<a+b))
{
if((a==b)&&(b==c))
printf("Equilateral traingle");
else if((a!=b)&&(b!=c)&&(a!=c))
printf("Scalene traingle");
Department of ISE, SCEM Page 2
Software testing laboratory 2019-20
else
printf("Isosceles traingle");
}
else
printf("Traingle cannot be formed");
return 0;
}

1.5TESTCASES

Table-1: Test case for Triangle Problem

TC Test Case Input Data Expected Output Actual Status


Id Description A B C Output

1 Two sides are same, 1 5 5 Isosceles


one side is given
different
input

2 Two sides are same, 2 5 5 Isosceles


one side is given
different
Input
3 All sides are same 5 5 5 Equilateral

4 Two sides are same, 9 5 5 Isosceles


one side is given
different
input
5 Two sides are same, 10 5 5 Not in Range
one side is given
different
input
6 Two sides are same, 5 1 5 Isosceles
one side is given
different
input
7 Two sides are same, 5 2 5 Isosceles
one side is given
different
input
8 Two sides are same, 5 9 5 Isosceles
one side is given

Department of ISE, SCEM Page 3


Software testing laboratory 2019-20
different
input
9 Two sides are same, 5 10 5 Not in Range
one side is given
different
input
10 Two sides are same, 5 5 1 Isosceles
one side is given
different
input
11 Two sides are same, 5 5 2 Isosceles
one side is given
different
input
12 Two sides are same, 5 5 9 Isosceles
one side is given
different
input
13 Two sides are same, 5 5 10 Not in Range
one side is given
different
Input

1.6 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 test cases Executed:
2. No. of Defects Raised:
3. No of test cases Passed:
4. No of test cases failed:

1.7 SNAPSHOTS

Department of ISE, SCEM Page 4


Software testing laboratory 2019-20
1.8 PRE-EXPERIMENT & POST-EXPERIMENT QUESTIONS

1. What is an error?
2. What is the use of testing software?
3. What are the types of software testing?
4. What is boundary value analysis?
5. What is white box testing and list the types of white box testing?
6. What is black box testing? What are the different black box testing techniques?

Department of ISE, SCEM Page 5


Software testing laboratory 2019-20

EXPERIMENT No. 02: Commission Problem-Boundary value Analysis


2.1 Objective 2.5 Test cases
2.2 Requirement specification 2.6 Execution
2.3 Design 2.7 Snapshots
2.4 Program Code 2.8 Pre-experiment & Post-experiment questions

2.1 OBJECTIVE

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.

2.2 REQUIREMENT SPECIFICATION

Problem Definition: The Commission Problem includes a salesperson in the former


Arizona Territory sold rifle locks, stocks and barrels made by a gunsmith in Missouri. Cost
includes

Locks- $45
Stocks- $30
Barrels- $25
The salesperson had to sell at least one complete rifle per month and production limits were
such that the most the salesperson could sell in a month was 70 locks, 80 stocks and 90 barrels.
After each town visit, the sales person sent a telegram to the Missouri gunsmith with the
number of locks, stocks and barrels sold in the town. At the end of the month, the salesperson
sent a very short telegram showing --1 lock sold. The gunsmith then knew the sales for the
month were complete and computed the salesperson‟s commission as follows:
On sales up to(and including) $1000= 10% On
the sales up to(and includes) $1800= 15% On
the sales in excess of $1800= 20%
The commission program produces a monthly sales report that gave the total number of locks,
stocks and barrels sold, the salesperson’s total dollar sales and finally the commission

2.3 DESIGN
ALGORITHM:

STEP 1: Define lockPrice=45.0, stockPrice=30.0, barrelPrice=25.0

STEP2: Input locks

Department of ISE, SCEM Page 6


Software testing laboratory 2019-20
STEP3: while(locks!=-1) „input device uses -1 to indicate end of data goto STEP 12

STEP4:input (stocks, barrels)

STEP5: compute lockSales, stockSales, barrelSales and sales

STEP6: output(“Total sales:” sales)

STEP7: if (sales > 1800.0) goto STEP 8 else goto STEP 9

STEP8: commission=0.10*1000.0; commission=commission+0.15 * 800.0;


commission = commission + 0.20 * (sales-1800.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

2.4 PROGRAM CODE:


#include<stdio.h>
int main()
{
int locks,stocks,barrels,tlocks,tstocks,tbarrels;
float lprice,sprice,bprice,sales=0,comm;
int c1,c2,c3,temp;
tlocks=0,tstocks=0,tbarrels=0;
lprice=45.0,sprice=30.0,bprice=25.0;
printf("Enter the number of locks and to exit the loop press -1\n");
scanf("%d",&locks);
while(locks!=-1)
{
c1=(locks<=0||locks>70);
printf("Enter the number of stocks and barrels");
scanf("%d%d",&stocks,&barrels);
c2=(stocks<=0||stocks>80);
c3=(barrels<=0||barrels>90);
if(c1)
printf("Value of locks not in range 1--70");
else
{
temp=locks+tlocks;
if(temp>70)
printf("New value of locks = %d not in range 1--70",temp);
else
tlocks=temp;
}
printf("Total locks = %d\n",tlocks);
Department of ISE, SCEM Page 7
Software testing laboratory 2019-20
if(c2)
printf("Value of stocks not in range 1--80");
else
{
temp=stocks+tstocks;
if(temp>80)
printf("New value of stocks = %d not in range 1--80",temp);
else
tstocks=temp;
}
printf("Total stocks = %d\n",tstocks);
if(c3)
printf("Value of barrels not in range 1--90");
else
{
temp=barrels+tbarrels;
if(temp>90)
printf("New value of barrels = %d not in range 1--90",temp);
else
tbarrels=temp;
}
printf("Total barrels = %d\n",tbarrels);
printf("Enter the number of locks and press -1 to exit the loop\n");
scanf("%d",&locks);
}
if(tlocks>0&&tstocks>0&&tbarrels>0)
{
printf("Total locks = %d\nTotal stocks = %d\nTotal barrels = %d\n",tlocks,tstocks,tbarrels);
sales=((tlocks*lprice)+(tstocks*sprice)+(tbarrels*bprice));
printf("Total sales is %f\n",sales);
if(sales>0)
{
if(sales>1800)
{
comm=0.10*1000.0;
comm=comm+0.15*800.0;
comm=comm+0.20*(sales-1800);
}
else if(sales>1000)
{
comm=0.10*1000.0;
comm=comm+0.15*(sales-1000);
}
else
comm=0.10*sales;
printf("Commission is %f \n",comm);
}
}
else
printf("There is no sales\n");

Department of ISE, SCEM Page 8


Software testing laboratory 2019-20
return 0;}

2.5 TESTCASES
Table-1: BVB Test case for Commission Problem

Input Data Expected Output Actual Output


TC Test Case
Description Status
Id Sales Commission Sales Commission
Locks Stocks Barrels

1 Input test cases 1 40 45 2370 334


for Locks=1,
Stocks=40,
Barrels=45
2 Input test cases 2 40 45 2415 343
for Locks=2,
Stocks=40,
Barrels=45
3 Input test cases 35 40 45 3900 640
for Locks=35,
Stocks=40,
Barrels=45
4 Input test cases 69 40 45 5430 946
for Locks=69,
Stocks=40,
Barrels=45
5 Input test cases 70 40 45 5475 955
for Locks=70,
Stocks=40,
Barrels=45
6 Input test cases 35 1 45 2730 406
for Locks=35,
Stocks=1,
Barrels=45
7 Input test cases 35 2 45 2760 412
for Locks=35,
Stocks=2,
Barrels=45
8 Input test cases 35 79 45 5070 874
for Locks=35,
Stocks=79,
Barrels=45

Department of ISE, SCEM Page 9


Software testing laboratory 2019-20
9 Input test cases 35 80 45 5100 880
for Locks=35,
Stocks=80,
Barrels=45
10 Input test cases 35 40 1 2800 420
for Locks=35,
Stocks=40,
Barrels=1
11 Input test cases 35 40 2 2825 925
for Locks=35,
Stocks=40,
Barrels=2
12 Input test cases 35 40 89 8000 860
for Locks=35,
Stocks=40,
Barrels=89
13 Input test cases 35 40 90 5025 865
for Locks=35,
Stocks=40,
Barrels=90

This is how we can apply BVA technique to create test cases for our Commission Problem.

2.6 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 TC‟s Executed:
2. No of Defects Raised:
3. No of TC‟s Pass:
4. No of TC‟s Failed:

Department of ISE, SCEM Page 10


Software testing laboratory 2019-20

2.7SNAPSHOTS:

2.8 PRE-EXPERIMENT & POST-EXPERIMENT QUESTIONS

1. What is Testing
2. What is fault? Name types of faults
3. What is commission problem?
4. What is boundary value analysis?
5. What is debugging?

Department of ISE, SCEM Page 11


Software testing laboratory 2019-20

EXPERIMENT No. 03: Next Date Function-Boundary value Analysis


3.1 Objective 3.5 Test cases
3.2 Requirement specification 3.6 Execution
3.3 Design 3.7 Snapshots
3.4 Program Code 3.8 Pre-experiment & Post-experiment questions

3.1 OBJECTIVE

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.

3.2 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.

3.3 DESIGN
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);

Department of ISE, SCEM Page 12


Software testing laboratory 2019-20
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

3.4 PROGRAM CODE:


#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,tday,tmonth,tyear;
Department of ISE, SCEM Page 13
Software testing laboratory 2019-20
char flag;
do{
flag='y';
printf("Enter todays date in ddmmyy format\n");
scanf("%d%d%d",&day,&month,&year);
tmonth=month;
tyear=year;
if(day<1||day>31)
{
printf("Value of day not in range 1--31\n");
flag='n';
}
if(month<1||month>12)
{
printf("Value of month not in range 1--12\n");
flag='n';
}
else if(check(day,month))
{
printf("Value of day not in range <=30");
flag='n';
}
if(year<1812||year>2018)
{
printf("Value of year not in range 1812--2018");
flag='n';
}
if(month==2)
{
if(isleap(year)&&day>29)
{
printf("Invalid input for leap year");
flag='n';
}
if(!isleap(year)&&day>28)
{
printf("Invalid input date for not a leap year");
flag='n';
}
}
}while(flag=='n');
switch(month)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10: if(day<31)
Department of ISE, SCEM Page 14
Software testing laboratory 2019-20
tday=day+1;
else
{
tday=1;
tmonth=month+1;
}
break;
case 4:
case 6:
case 9:
case 11: if(day<30)
tday=day+1;
else
{
tday=1;
tmonth=month+1;
}
break;
case 12:if(day<31)
tday=day+1;
else
{
tday=1;
tmonth=1;
if(year==2018)
{
printf("Next year is out of boundary value of year");
}
else
tyear=year+1;
}
break;
case 2: if(day<28)
tday=day+1;
else if(isleap(year)&&day==28)
tday=day+1;
else if(day==28||day==29)
{
tday=1;
tmonth=3;
}
break;
}
printf("Next day is %d/%d/%d\n",tday,tmonth,tyear);
return 0;
}

Department of ISE, SCEM Page 15


Software testing laboratory 2019-20
3.5 TESTCASES
Technique used: Boundary value analysis
Table-1: Test case for Next Date Problem

TC Test Case Input Data Expected Actual Status


Id Description
DD MM YYYY Output Output

1 Invalid Month 15 15 1990 Invalid Invalid Pass


Month Month
2 Invalid Day 32 03 1990 Invalid Invalid Pass
Date Date
3 Invalid Year 15 03 1800 Invalid Invalid Pass
Year Year
4 Min date 00 03 2000 Invalid Invalid Pass
Date Date
5 Valid input 30 03 2000 31/03/2000 31/03/2000 Pass

6 Valid date 02 03 2000 03/03/2000 03/03/2000 Pass

7 Invalid Date 32 08 2000 Invalid Date Invalid Date Pass


8 Invalid month 15 00 2000 Invalid Invalid Pass
Month Month
9 Valid input 15 11 2000 16/11/2000 16/11/2000 Pass

10 Valid input 15 02 2000 16/02/2000 16/02/2000 Pass

11 Invalid Month 15 13 2000 Invalid Invalid Pass


Month Month
12 Invalid year 15 03 1811 Invalid Invalid Pass
Year Year
13 Valid input 15 03 2011 16/03/2011 16/03/2011 Pass

14 Valid input 15 03 1813 16/03/1813 16/03/1813 Pass

15 Invalid year 15 03 2013 Invalid Invalid Pass


Year Year

This is how we can apply BA technique to create test cases for our Next Date Problem.

3.6 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

Department of ISE, SCEM Page 16


Software testing laboratory 2019-20
Test Report:
1. No of TC‟s Executed:
2. No of Defects Raised:
3. No of TC‟s Pass:
4. No of TC‟s Failed:
3.7 SNAPSHOTS:

3.8 PRE-EXPERIMENT & POST-EXPERIMENT QUESTIONS

1. Differentiate between a) Functional Testing and Structural Testing.


2. What are the conditions for next date problem?
3. What is the test case?
4. What is glass box testing?
5. What is the procedure for manual testing?

Department of ISE, SCEM Page 17


Software testing laboratory 2019-20
EXPERIMENT No. 04: Triangle Problem-Equivalence Class Partitioning
4.1 Objective 4.5 Test cases
4.2 Requirement specification 4.6 Execution
4.3 Design 4.7 Snapshots
4.4 Program Code 4.8 Pre-experiment & Post-experiment questions

4.1 Objective:

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.

4.2 Requirement Specification:

R1. The system should accept 3 positive integer numbers (a, b, c) which represents 3 sides
of the triangle.
R2. Based on the input should determine if a triangle can be formed or not.
R3. If the requirement R2 is satisfied then the system should determine the type of the
triangle, which can be
• Equilateral (i.e. all the three sides are equal)
• Isosceles (i.e. two sides are equal)
• Scalene (i.e. All the three sides are unequal)
R4. Upper Limit for the size of any side is 10

4.3 DESIGN
Form the given requirements we can draw the following conditions:
C1: a<b+c?
C2: b<a+c?
C3: c<a+b?
C4: a=b?

C5: a=c?
C6: b=c?
According to the property of the triangle, if any one of the three conditions C1, C2 and C3
are not satisfied then triangle cannot be constructed. So only when C1, C2 and C3 are true
the triangle can be formed, then depending on conditions C4, C5 and C6 we can decide
what type of triangle will be formed. (i.e requirement R3).
ALGORITHM:
Department of ISE, SCEM Page 18
Software testing laboratory 2019-20
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

4.4 PROGRAM CODE


#include<stdio.h>
#include<stdlib.h>
int main()
{
int a,b,c;
printf("Enter the three sides
of traingle");

scanf("%d%d%d",&a,&b,&
c);

if((a<1||a>10)||(b<1||b>10)||(
c<1||c>10))
{
printf("Out of range
values");
exit(0);
}

if((a<b+c)&&(b<a+c)&&(c
<a+b))
{
if((a==b)&&(b==c))
printf("Equilateral
traingle");
else
if((a!=b)&&(b!=c)&&(a!=c)
)

printf("Scalene traingle");
else
Department of ISE, SCEM Page 19
Software testing laboratory 2019-20
printf("Isosceles
traingle");
}
else
printf("Traingle cannot
be formed");
return 0;
}

4.5 TESTCASES

TC Test Case Input Data Expected Output Actual Status


Id Description a b C Output

1 Three sides are 3 4 5 Scalene Scalene Pass


different
2 All Values are 5 5 5 Equilateral Equilateral Pass
same
3 Two sides are 2 5 5 Isoceles Isoceles Pass
same, one side
is different
4 Value of a=10, 10 5 5 Triangle cannot be Triangle cannot Pass
b=5, c=5 formed be formed

Table-1: Weak Normal and Strong normal equivalence 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}

Table-2 Weak Robust Test case for Triangle Problem

Department of ISE, SCEM Page 20


Software testing laboratory 2019-20

TC Test Case Input Data Expected Output Actual Status


Id Description a b C Output

1 Since a>10 11 3 2 Out of range Out of range Pass


the values of
one variable
is greater
than the
range
2 Since b>10 3 11 2 Out of range Out of range Pass
the values of
one variable
is greater
than the
range
3 Since c>10 3 2 11 Out of range Out of range Pass
the values of
one variable
is greater
than 10
4 Since a<1the 0 4 5 Out of range Out of range Pass
value of one
variable is
lesser than
the range
5 Since b<1the 4 0 5 Out of range Out of range Pass
value of one
variable is
lesser than
the range
6 Since c<1the 4 5 0 Out of range Out of range Pass
value of one
variable is
lesser than
the range

Table-3: Strong Robust Test case for Triangle Problem

TC Test Case Input Data Expected Output Actual Status


Id Description a b C Output

1 Since a, b>10 11 11 5 Out of range Out of range Pass


the values of
two variables
is greater
than the
range
2 Since b, c>10 5 11 11 Out of range Out of range Pass
the values of
two variables
Department of ISE, SCEM Page 21
Software testing laboratory 2019-20
is greater
than the
range
3 Since a, c>10 11 5 11 Out of range Out of range Pass
the values of
two variables
is greater
than range
4 Since a, b<0 0 0 5 Out of range Out of range Pass
the value of
two variables
is lesser than
the range
5 Since b, 5 0 0 Out of range Out of range Pass
c<0the value
of two
variables is
lesser than
the range
6 Since a,c<0 0 5 0 Out of range Out of range Pass
the value of
two variables
is lesser than
the range
7 Since all the 11 11 11 Out of range Out of range Pass
values
greater than
10 i.e greater
than the
range
8 Since all the 0 0 0 Out of range Out of range Pass
values lesser
than 0 i.e
lesser than
the range

4.6 EXECUTION:
Execute the program and test the test cases in Table-1, Table-2 and Table-3 against program
and complete the table with for Actual output column and Status column
Test Report
1. No of TC‟s Executed:
2. No of Defects Raised:
3. No of TC‟s Pass:
4. No of TC‟s Failed:

4.7 SNAPSHOTS:

Department of ISE, SCEM Page 22


Software testing laboratory 2019-20

4.8 PRE-EXPERIMENT & POST-EXPERIMENT QUESTIONS

1. What is equivalence partitioning?


2. What is black box testing?
3. What are the different black box testing techniques?
4. What is Non-Functional Testing?
5. What is Functional Testing?

Department of ISE, SCEM Page 23


Software testing laboratory 2019-20

EXPERIMENT No. 05: Commission Problem-Equivalence Class Partitioning


5.1 Objective 5.5 Test cases
5.2 Requirement specification 5.6 Execution
5.3 Design 5.7 Snapshots
5.4 Program Code 5.8 Pre-experiment & Post-experiment questions

5.1 OBJECTIVES:
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

5.2 REQUIREMENT SPECIFICATION

Problem Definition: The Commission Problem includes a salesperson in the former


Arizona Territory sold rifle locks, stocks and barrels made by a gunsmith in Missouri. Cost
includes

Locks- $45
Stocks- $30
Barrels- $25
The salesperson had to sell at least one complete rifle per month and production limits were
such that the most the salesperson could sell in a month was 70 locks, 80 stocks and 90 barrels.
After each town visit, the sales person sent a telegram to the Missouri gunsmith with the
number of locks, stocks and barrels sold in the town. At the end of the month, the salesperson
sent a very short telegram showing --1 lock sold. The gunsmith then knew the sales for the
month were complete and computed the salesperson‟s commission as follows:
On sales up to(and including) $1000= 10% On
the sales up to(and includes) $1800= 15% On
the sales in excess of $1800= 20%
The commission program produces a monthly sales report that gave the total number of locks,
stocks and barrels sold, the salesperson‟s total dollar sales and finally the commission
5.3 DESIGN

Algorithm
STEP 1: Define lockPrice=45.0, stockPrice=30.0, barrelPrice=25.0

STEP2: Input locks

Department of ISE, SCEM Page 24


Software testing laboratory 2019-20
STEP3: while(locks!=-1) „input device uses -1 to indicate end of data goto STEP 12

STEP4:input (stocks, barrels)

STEP5: compute lockSales, stockSales, barrelSales and sales

STEP6: output(“Total sales:” sales)

STEP7: if (sales > 1800.0) goto STEP 8 else goto STEP 9

STEP8: commission=0.10*1000.0; commission=commission+0.15 * 800.0;

commission = commission + 0.20 * (sales-1800.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.4 PROGRAM CODE:

#include<stdio.h>
int main()
{
int locks,stocks,barrels,tlocks,tstocks,tbarrels;
float lprice,sprice,bprice,sales=0,comm;
int c1,c2,c3,temp;
tlocks=0,tstocks=0,tbarrels=0;
lprice=45.0,sprice=30.0,bprice=25.0;
printf("Enter the number of locks and to exit the loop press -1\n");
scanf("%d",&locks);
while(locks!=-1)
{
c1=(locks<=0||locks>70);
printf("Enter the number of stocks and barrels");
scanf("%d%d",&stocks,&barrels);
c2=(stocks<=0||stocks>80);
c3=(barrels<=0||barrels>90);
if(c1)
printf("Value of locks not in range 1--70");
else
{
temp=locks+tlocks;
if(temp>70)
printf("New value of locks = %d not in range 1--70",temp);
else
tlocks=temp;
}
Department of ISE, SCEM Page 25
Software testing laboratory 2019-20
printf("Total locks = %d\n",tlocks);
if(c2)
printf("Value of stocks not in range 1--80");
else
{
temp=stocks+tstocks;
if(temp>80)
printf("New value of stocks = %d not in range 1--80",temp);
else
tstocks=temp;
}
printf("Total stocks = %d\n",tstocks);
if(c3)
printf("Value of barrels not in range 1--90");
else
{
temp=barrels+tbarrels;
if(temp>90)
printf("New value of barrels = %d not in range 1--90",temp);
else
tbarrels=temp;
}
printf("Total barrels = %d\n",tbarrels);
printf("Enter the number of locks and press -1 to exit the loop\n");
scanf("%d",&locks);
}
if(tlocks>0&&tstocks>0&&tbarrels>0)
{
printf("Total locks = %d\nTotal stocks = %d\nTotal barrels = %d\n",tlocks,tstocks,tbarrels);
sales=((tlocks*lprice)+(tstocks*sprice)+(tbarrels*bprice));
printf("Total sales is %f\n",sales);
if(sales>0)
{
if(sales>1800)
{
comm=0.10*1000.0;
comm=comm+0.15*800.0;
comm=comm+0.20*(sales-1800);
}
else if(sales>1000)
{
comm=0.10*1000.0;
comm=comm+0.15*(sales-1000);
}
else
comm=0.10*sales;
printf("Commission is %f \n",comm);
}
}
else
printf("There is no sales\n");
Department of ISE, SCEM Page 26
Software testing laboratory 2019-20
return 0;
}

5.5 TESTCASES:
First attempt
We will have eight weak robust test cases.

Input Data Expected Output Actual Output


TC Test Case
Description Status
Id Stock
Locks Barrels Sales Commission Sales Commission
s
1 When lock=-1 -1 40 45 Terminates out of
loop

2 When all 30 40 45 3675 595


values are
within range

3 Locks out of -2 40 45 No No
range sales commissio
n

4 Stocks out of 35 -2 45 No No
range sales commissio
n

5 Barrels out of 35 40 -2 No No
range sales commissio
n

6 Locks out of 71 40 45 No No
range sales commissio
n

7 Stocks out of 35 81 45 No No
range sales commissio
n

8 Barrels out of 35 40 91 No No
range sales commissio
n

Department of ISE, SCEM Page 27


Software testing laboratory 2019-20

Second attempt:
Strong robust equivalence class test cases:

Input Data Expected Output Actual Output


TC Test Case
Description Status
Id Sales Commission Sales Commission
Locks Stocks Barrels

1 Locks & stocks -2 -2 45 No sales No


out of range commissio
n

2 Stocks & 35 -2 -2 No sales No


barrels out of commission
range

3 Locks & -2 40 -2 No sales No


Barrels out of commission
range

4 Locks & 71 40 91 No sales No


Barrels out of commission
range

5 Stocks & 35 81 91 No sales No


barrels out of commission
range

6 Locks & 71 81 45 No sales No


Stocks out of commission
range

7 Locks , Stocks -2 -2 -2 No sales No


& barrels out commission
of range

8 Locks , Stocks 71 81 91 No sales No


& barrels out commission
of range

Department of ISE, SCEM Page 28


Software testing laboratory 2019-20

Weak Normal & Strong Normal

Input Data Expected Output Actual Output


TC Test Case
Description Status
Id Sales Commission Sales Commission
Locks Stocks Barrels

1 All normal 35 40 45 3900 640


values for
locks, stocks &
barrels

5.6 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 TC‟s Executed:
2. No of Defects Raised:
3. No of TC‟s Pass:
4. No of TC‟s Failed:

Department of ISE, SCEM Page 29


Software testing laboratory 2019-20
5.7 SNASHOTS

5.8 PRE-EXPERIMENT & POST-EXPERIMENT QUESTIONS


1. What is an error?
2. What is a failure?
3. What is weak robust and strong robust ?
4. What is the difference between weak normal and strong normal?
5. How we perform equivalence class partitioning?

Department of ISE, SCEM Page 30


Software testing laboratory 2019-20
EXPERIMENT No. 06: Nextdate Function-Equivalence Class Value Testing
6.1 Objective 6.5 Test cases
6.2 Requirement specification 6.6 Execution
6.3 Design 6.7 Snapshots
6.4 Program Code 6.8 Pre-experiment & Post-experiment questions

6.1 OBJECTIVES:
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.
6.2 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.

6.1 DESIGN

Algorithm
STEP 1: Input date in format DD.MM.YYYY

STEP2: if MM is 01, 03, 05,07,08,10 do STEP3 else STEP6

Department of ISE, SCEM Page 31


Software testing laboratory 2019-20
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

6.2 PROGRAM CODE:


#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)

Department of ISE, SCEM Page 32


Software testing laboratory 2019-20
{

if(((year%4==0)&&(year%100!=0))||(year%400==0))

return 1;

else

return 0;

int main()

int day,month,year,tday,tmonth,tyear;

char flag;

do{

flag='y';

printf("Enter todays date in ddmmyy format\n");

scanf("%d%d%d",&day,&month,&year);

tmonth=month;

tyear=year;

if(day<1||day>31)

printf("Value of day not in range 1--31\n");

flag='n';

if(month<1||month>12)

printf("Value of month not in range 1--12\n");

flag='n';

else if(check(day,month))
Department of ISE, SCEM Page 33
Software testing laboratory 2019-20
{

printf("Value of day not in range <=30");

flag='n';

if(year<1812||year>2018)

printf("Value of year not in range 1812--2018");

flag='n';

if(month==2)

if(isleap(year)&&day>29)

printf("Invalid input for leap year");

flag='n';

if(!isleap(year)&&day>28)

printf("Invalid input date for not a leap year");

flag='n';

}while(flag=='n');

switch(month)

case 1:

case 3:
Department of ISE, SCEM Page 34
Software testing laboratory 2019-20
case 5:

case 7:

case 8:

case 10: if(day<31)

tday=day+1;

else

tday=1;

tmonth=month+1;

break;

case 4:

case 6:

case 9:

case 11: if(day<30)

tday=day+1;

else

tday=1;

tmonth=month+1;

break;

case 12:if(day<31)

tday=day+1;

else

tday=1;
Department of ISE, SCEM Page 35
Software testing laboratory 2019-20
tmonth=1;

if(year==2018)

printf("Next year is out of boundary value of year");

else

tyear=year+1;

break;

case 2: if(day<28)

tday=day+1;

else if(isleap(year)&&day==28)

tday=day+1;

else if(day==28||day==29)

tday=1;

tmonth=3;

break;

printf("Next day is %d/%d/%d\n",tday,tmonth,tyear);

return 0;

6.5 TESTING
Test Case design

Department of ISE, SCEM Page 36


Software testing laboratory 2019-20
The NextDate function is a function which will take in a date as input and produces as output
the next date in the Georgian calendar. It uses three variables (month, day and year) which each
have valid and invalid intervals.

Table 1: Valid Case

TC Test Case Input Data Expected Actual Status


Id Description DD MM YYYY Output Output

1 Valid case 15 6 1900 16/6/1900

Weak Robust:

TC Test Case Input Data Expected Actual Status


Id Description DD MM YYYY Output Output
1 Valid Range 15 6 1912 16/6/1912
2 Invalid date -1 6 1912 Day not in range
3 Invalid month 15 -1 1912 Month not in
range
4 Invalid year 15 6 1911 year not in range

5 Invalid date 32 6 1912 Day not in range

6 Invalid month 15 13 1912 Month not in


range
7 Invalid year 15 6 2013 year not in range

Strong Robust:

TC Test Case Input Data Expected Actual Status


Id Description DD MM YYYY Output Output
1 Invalid date & -1 -1 1912 Not in range
month
2 Invalid date & -1 6 -1 Not in range
year
3 Invalid month & 15 -1 -1 Not in range
year
4 Invalid date & 32 13 1912 Not in range
month
5 Invalid date & 32 6 2013 Not in range
year
6 Invalid month & 15 13 2013 Not in range
year
7 Invalid date, -1 -1 -1 Not in range
month & year
Department of ISE, SCEM Page 37
Software testing laboratory 2019-20
8 Invalid date, 32 13 2013 Not in range
month & year

Strong Normal:

TC ID Test Case Input Data Expected Output Actual Status


Description DD MM YYYY Output

1 Valid Condition 14 6 2000 15/6/2000

2 Valid Input 14 6 1996 15/6/1996

3 Valid Input 14 6 2002 15/6/2002

4 Valid Input 29 6 2000 30/6/2000

5 Valid Input 29 6 1996 30/6/1996

6 Valid Input 29 6 2002 30/6/2002

7 Valid Input 30 6 2000 1/7/2000

8 Valid Input 30 6 1996 1/7/1996

9 Valid Input 30 6 2002 1/7/2002

10 Invalid Range 31 6 2000 Not in Range

11 Invalid Range 31 6 1996 Not in Range

12 Invalid Range 31 6 2002 Not in Range

13 Valid Range 14 7 2000 15/7/2000

14 Valid Range 14 7 1996 15/7/1996

15 Valid Range 14 7 2002 15/7/2002

16 Valid Input 29 7 1996 30/7/1996

17 Valid Input 29 7 2000 30/7/2000

18 Valid Input 29 7 2002 30/7/2002

19 Valid Input 30 7 2000 31/7/2000

20 Valid Input 30 7 1996 31/7/1996

21 Valid Input 30 7 2002 31/7/2002

22 Valid Input 31 7 1996 1/8/1996

Department of ISE, SCEM Page 38


Software testing laboratory 2019-20
23 Valid Input 31 7 2000 1/8/2000

24 Valid Input 31 7 2002 1/8/2002

25 Valid Input 29 2 1996 1/3/1996

26 Invalid Input 29 2 2000 Not in range

27 Invalid Input 29 2 2002 Not in range

28 Invalid Input 30 2 1996 Not in range

29 Invalid Input 30 2 2000 Not in range

30 Invalid Input 30 2 2002 Not in range

31 Invalid Input 31 2 1996 Not in range

32 Invalid Input 31 2 2000 Not in range

33 Invalid Input 31 2 2002 Not in range

34 Valid Input 14 2 1996 15/2/1996

35 Valid Input 14 2 2000 15/2/2000

36 Valid Input 14 2 2002 15/2/2002

Weak Normal:

TC Test Case Input Data Expected Actual Status


Id Description DD MM YYYY Output Output
1 Valid Condition 14 6 2000 15/6/2000
2 Valid Input 29 7 1996 30/7/1996
3 Invalid Date 30 2 2002 not in range

4 Invalid date 31 6 2000 not in range

6.6 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:
6.6.1 No of TC‟s Executed:
6.6.2 No of Defects Raised:

Department of ISE, SCEM Page 39


Software testing laboratory 2019-20
6.6.3 No of TC‟s Pass:
6.6.4 No of TC‟s Failed:

6.7 SNAPSHOTS:

6.8PRE-EXPERIMENT & POST-EXPERIMENT QUESTIONS


1. What is an error?
2. What are the conditions for next date problem?
3. What are the difference between manual and automation testing?
4. Explain weak robust and strong robust
5. Explain weak normal and strong normal

Department of ISE, SCEM Page 40


Software testing laboratory 2019-20

EXPERIMENT No. 07: Triangle Problem-Decision Table Approach


7.1 Objective 7.5 Test cases
7.2 Requirement specification 7.6 Execution
7.3 Design 7.7 Snapshots
7.4 Program Code 7.8 Pre-experiment & Post-experiment questions

7.1 OBJECTIVES:

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.

7.2 REQUIREMENT SPECIFICATION:

R1. The system should accept 3 positive integer numbers (a, b, c) which represents 3 sides of
the triangle. Based on the input it should determine if a triangle can be formed or not.
R2. If the requirement R1 is satisfied then the system should determine the type of the triangle,
which can be
• Equilateral (i.e. all the three sides are equal)
• Isosceles (i.e Two sides are equal)
• Scalene (i.e All the three sides are unequal)
else suitable error message should be displayed. Here we assume that user gives three positive
integer numbers as input.

7.3 DESIGN:
Form the given requirements we can draw the following conditions:
C1: a<b+c?
C2: b<a+c?
C3: c<a+b?
C4: a=b?
C5: a=c?
C6: b=c?
According to the property of the triangle, if any one of the three conditions C1, C2 and C3 are
not satisfied then triangle cannot be constructed. So only when C1, C2 and C3 are true the
triangle can be formed, then depending on conditions C4, C5 and C6 we can decide what type
of triangle will be formed. (i.e requirement R2).

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.
Department of ISE, SCEM Page 41
Software testing laboratory 2019-20

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

7.4 PROGRAM CODE:


#include<stdio.h>
#include<stdlib.h>
int main()
{
int a,b,c;
printf("Enter the three
sides of traingle");

scanf("%d%d%d",&a,&b
,&c);

if((a<1||a>10)||(b<1||b>10
)||(c<1||c>10))
{
printf("Out of range
values");
exit(0);
}

if((a<b+c)&&(b<a+c)&&
(c<a+b))
{
if((a==b)&&(b==c))
printf("Equilateral
traingle");
else
if((a!=b)&&(b!=c)&&(a!
=c))
printf("Scalene
traingle");
else
printf("Isosceles
Department of ISE, SCEM Page 42
Software testing laboratory 2019-20
traingle");
}
else
printf("Traingle cannot
be formed");
return 0;
}

1. TESTCASES:
Technique Used: Decision Table Approach
Decision Table-Based Testing has been around since the early 1960‟s; it is used to depict
complex logical relationships between input data. A Decision Table is the method used to build
a complete set of test cases without using the internal structure of the program in question. In
order to create test cases we use a table to contain the input and output values of a program.

The decision table is as given below:


Condition Entries (Rules)
Conditions R R
R1 R2 R3 R4 R5 R6 R7 R8 R9
10 11
C1: a<b+c? F T T T T T T T T T T
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? -- -- -- F T T T F F F T
C5: a=c? -- -- -- T F T F T F F T
C6: b=c? -- -- -- T T F F F T F T
Actions Action Entries
a1: Not a
X X X
Triangle
a2: Scalene X
a3: Isosceles X X X
a4: Equilateral X
a5: Impossible X X X

The “--“ symbol in the table indicates don‟t care values. The table shows the six conditions and
5 actions. All the conditions in the decision table are binary; hence, it is called as “Limited
Entry decision table”.
Each column of the decision table represents a test case. That is,
The table is read as follows:
 Action: Not a Triangle

Department of ISE, SCEM Page 43


Software testing laboratory 2019-20
1. When condition C1 is false we can say that with the given „a‟ „b‟ and „c‟ values, it‟s Not a
triangle.
2. Similarly condition C2 and C3, if any one of them are false, we can say that with the given
„a‟ „b‟ and „c‟ values it‟s Not a triangle.
 Action: Impossible
3. When conditions C1, C2, C3 are true and two conditions among C4, C5, C6 is true, there is
no chance of one conditions among C4, C5, C6 failing. So we can neglect these rules.
Example: if condition C4: a=b is true and C5: a=c is true
Then it is impossible, that condition C6: b=c will fail, so the action is Impossible.
 Action: Isosceles
4. When conditions C1, C2, C3 are true and any one condition among C4, C5 and C6 is true
with remaining two conditions false then action is Isosceles triangle.
Example: If condition C4: a=b is true and C5: a=c and C6: b=c are false, it means two sides
are equal. So the action will be Isosceles triangle.
 Action: Equilateral
5. When conditions C1, C2, C3 are true and also conditions C4, C5 and C6 are true then, the
action is Equilateral triangle.
 Action: Scalene
6. When conditions C1, C2, C3 are true and conditions C4, C5 and C6 are false i.e sides a, b
and c are different, then action is Scalene triangle.
Number of Test Cases = Number of Rules.
Using the decision table we obtain 11 functional test cases: 3 impossible cases, 3 ways of
failing the triangle property, 1 way to get an equilateral triangle, 1 way to get a scalene triangle,
and 3 ways to get an isosceles triangle.
Deriving test cases using
Decision Table Approach:
Test Cases:

TC Expected Actual
Test Case A BC Status
ID Output Output
Description
Testing for Not a
1 6 4 1
Rule 1 Triangle
Testing for Not a
2 1 5 3
Rule 2 Triangle
Testing for Not a
3 1 2 4
Rule 3 Triangle

Department of ISE, SCEM Page 44


Software testing laboratory 2019-20
Testing for
4 2 2 3 Isosceles
Rule 7
Testing for
5 2 3 2 Isosceles
Rule 8
Testing for
6 3 2 2 Isosceles
Rule 9
Testing for
7 3 4 5 Scalene
Rule 10
Testing for Rule 11
8 5 5 5 Equilateral

2. EXECUTION
Execute the program against the designed test cases and complete the table for Actual output
column and status column.
Test Report:
7.2.1 No of TC‟s Executed: 08
7.2.2 No of Defects Raised:
7.2.3 No of TC‟s Pass:
7.2.4 No of TC‟s 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.

3. SNAPSHOTS:
1. Output screen of Triangle cannot be formed

Department of ISE, SCEM Page 45


Software testing laboratory 2019-20

4. PRE-EXPERIMENT & POST-EXPERIMENT QUESTIONS

1. Explain the decision table approach


2. What you mean by don’t care values?
3. How many test cases in the decision table approach?
4. What are the differences between boundary value analysis and decision table approach?

Department of ISE, SCEM Page 46


Software testing laboratory 2019-20
EXPERIMENT No. 08: Commission problem-Decision Table Based Testing
8.1 Objective 8.5 Test cases
8.2 Requirement specification 8.6 Execution
8.3 Design 8.7 Snapshots
8.4 Program Code 8.8 Pre-experiment & Post-experiment questions

8.1 Objectives:
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

8.2 REQUIREMENT SPECIFICATION:


R1: The system should read the number of Locks, Stocks and Barrels sold in a month. (i.e
1≤ Locks≤ 70)
(i.e 1 ≤ Stocks ≤ 80)
(i.e 1 ≤ Barrels ≤ 90).
R2: If R1 is satisfied the system should compute the salesperson‟s commission depending on
the total number of Locks, Stocks & Barrels sold else it should display suitable error message.
Following is the percentage of commission for the sales done:
10% on sales up to (and including) $1000
15% on next $800
20% on any sales in excess of $1800
Also the system should compute the total dollar sales. The system should output salespersons
total dollar sales, and his commission.

8.3 DESIGN:
Form the given requirements we can draw the following conditions:
C1: 1≤locks≤70? Locks = -1? (occurs if locks = -1 is used to control input
iteration).
C2: 1≤stocks≤80?
C3: 1≤barrels≤90? Here C1 can be expanded
C4: sales>1800? as: C1a: 1≤locks

C5: sales>1000? C1b: locks≤70

C6: sales≤1000?

Department of ISE, SCEM Page 47


Software testing laboratory 2019-20

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.

8.4 PROGRAM CODE:

#include<stdio.h>
int main()
{
int locks,stocks,barrels,tlocks,tstocks,tbarrels;
float lprice,sprice,bprice,sales=0,comm;
int c1,c2,c3,temp;
tlocks=0,tstocks=0,tbarrels=0;
lprice=45.0,sprice=30.0,bprice=25.0;
printf("Enter the number of locks and to exit the loop press -1\n");
scanf("%d",&locks);
while(locks!=-1)
{
c1=(locks<=0||locks>70);
printf("Enter the number of stocks and barrels");
scanf("%d%d",&stocks,&barrels);
c2=(stocks<=0||stocks>80);
c3=(barrels<=0||barrels>90);
if(c1)
printf("Value of locks not in range 1--70");
else
{
Department of ISE, SCEM Page 48
Software testing laboratory 2019-20
temp=locks+tlocks;
if(temp>70)
printf("New value of locks = %d not in range 1--70",temp);
else
tlocks=temp;
}
printf("Total locks = %d\n",tlocks);
if(c2)
printf("Value of stocks not in range 1--80");
else
{
temp=stocks+tstocks;
if(temp>80)
printf("New value of stocks = %d not in range 1--80",temp);
else
tstocks=temp;
}
printf("Total stocks = %d\n",tstocks);
if(c3)
printf("Value of barrels not in range 1--90");
else
{
temp=barrels+tbarrels;
if(temp>90)
printf("New value of barrels = %d not in range 1--90",temp);
else
tbarrels=temp;
}
printf("Total barrels = %d\n",tbarrels);
printf("Enter the number of locks and press -1 to exit the loop\n");
scanf("%d",&locks);
}
if(tlocks>0&&tstocks>0&&tbarrels>0)
{
printf("Total locks = %d\nTotal stocks = %d\nTotal barrels = %d\n",tlocks,tstocks,tbarrels);
sales=((tlocks*lprice)+(tstocks*sprice)+(tbarrels*bprice));
printf("Total sales is %f\n",sales);
if(sales>0)
{
if(sales>1800)
{
comm=0.10*1000.0;
comm=comm+0.15*800.0;
comm=comm+0.20*(sales-1800);
}
else if(sales>1000)
{
comm=0.10*1000.0;
comm=comm+0.15*(sales-1000);
}
else
Department of ISE, SCEM Page 49
Software testing laboratory 2019-20
comm=0.10*sales;
printf("Commission is %f \n",comm);
}
}
else
printf("There is no sales\n");
return 0;
}

8.5 TESTCASES
Technique Used: Decision Table Approach

The decision table is given below:


Condition Entries (Rules)
Conditions
R1 R2 R3 R4 R5 R6 R7 R8 R9
C1: locks=-1 T F F F F F F F F
C2: 1<=locks<=70 -- T F F T T F T F
C3: 1<=stocks<=80 -- T F T F T F F T
C4:1<=barrels<=90 -- T F T T F T F F
Actions Action Entries
a1: terminate
X
loop

a2: invalid locks X X X X


a3: invalid stocks X X X X
a4: invalid barrels X X X X
a5: calculate X X X X X X X X
tlocks, tstocks,
tbarrels
a6: calculate sales X
a7: processed in X
commission in
decision table

The commission table is given below:


Conditions Condition Entries (Rules)
R10 R11 R12 R13
C1: sales <0 T F F F
C2: sales>0 & sales<1000 -- T F F
C3: sales>1000 & sales< 1800 -- -- T F
C4: sales>1800 -- -- -- T
Actions Action Entries
Department of ISE, SCEM Page 50
Software testing laboratory 2019-20
a1: terminate X
a2: comm = 10*sales X
a3: comm = 10% * 1000+(sales- X
1000)*15
a4: comm = 10% * X
1000+15%*800+(sales-
1800)*20%

Deriving Test Cases Using Decision Table Approach:

Test Cases:

Input Data Expected Output Actual Output


TC Test Case
Description Status
Id Sales Commission Sales Commission
Locks Stocks Barrels

1 R1 & R10 -1 Terminate

2 R2 & R13 35 40 45 3900 640


3 R3 71 81 91 No No Comm
sales
4 R4 -2 90 45 No No Comm
sales
5 R5 35 -2 45 No No Comm
sales
6 R6 35 40 -2 No No Comm
sales
7 R7 -2 -2 45 No No Comm
sales
8 R8 35 -2 -2 No No Comm
sales
9 R9 -2 40 -2 No No Comm
sales
10 R11 5 5 5 500 50
11 R12 15 15 15 1500 55

8.6 EXECUTION & RESULT DISCUSION:


Execute the program against the designed test cases and complete the table for Actual output
column and status column.

Department of ISE, SCEM Page 51


Software testing laboratory 2019-20
TEST REPORT:
8.6.1 No of TC‟s Executed:
8.6.2 No of Defects Raised:
8.6.3 No of TC‟s Pass:
8.6.4 No of TC‟s Failed:
The commission problem is not well served by a decision table analysis because it has very
little decisional. Because the variables in the equivalence classes are truly independent, no
impossible rules will occur in a decision table in which condition correspond to the equivalence
classes.

8.7 SNAPSHOTS:

8.8PRE-EXPERIMENT & POST-EXPERIMENT QUESTIONS

1. What is an error?
2. What is the use of testing software?
3. How is the decision table approach carried out?
4. What are the types of software testing?
5. What are the different black box testing techniques?

Department of ISE, SCEM Page 52


Software testing laboratory 2019-20

EXPERIMENT No. 09: Commission Problem-Dataflow Testing


9.1 Objective 9.5 Test cases
9.2 Requirement specification 9.6 Execution
9.3 Design 9.7 Snapshots
9.4 Program Code 9.8 Pre-experiment & Post-experiment questions

9.1 Objectives:
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.

9.2 REQUIREMENT SPECIFICATION

Problem Definition: The Commission Problem includes a salesperson in the former


Arizona Territory sold rifle locks, stocks and barrels made by a gunsmith in Missouri.
Cost includes

Locks- $45
Stocks- $30
Barrels- $25
The salesperson had to sell at least one complete rifle per month and production limits were
such that the most the salesperson could sell in a month was 70 locks, 80 stocks and 90
barrels.
After each town visit, the sales person sent a telegram to the Missouri gunsmith with the
number of locks, stocks and barrels sold in the town. At the end of the month, the
salesperson sent a very short telegram showing --1 lock sold. The gunsmith then knew the
sales for the month were complete and computed the salesperson‟s commission as follows:
On sales up to(and including) $1000= 10% On
the sales up to(and includes) $1800= 15% On
the sales in excess of $1800= 20%
The commission program produces a monthly sales report that gave the total number of
locks, stocks and barrels sold, the salesperson‟s total dollar sales and finally the
commission
9.3 DESIGN

Algorithm
STEP 1: Define lockPrice=45.0, stockPrice=30.0, barrelPrice=25.0

STEP2: Input locks

Department of ISE, SCEM Page 53


Software testing laboratory 2019-20
STEP3: while(locks!=-1) „input device uses -1 to indicate end of data goto STEP 12

STEP4:input (stocks, barrels)

STEP5: compute lockSales, stockSales, barrelSales and sales

STEP6: output(“Total sales:” sales)

STEP7: if (sales > 1800.0) goto STEP 8 else goto STEP 9


STEP8: commission=0.10*1000.0; commission=commission+0.15 * 800.0;

commission = commission + 0.20 * (sales-1800.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

9.4 PROGRAM CODE:


#include<stdio.h>
int main()
{
int locks,stocks,barrels,tlocks,tstocks,tbarrels;
float lprice,sprice,bprice,sales=0,comm,lsales,ssales,bsales;
tlocks=0,tstocks=0,tbarrels=0;
lprice=45.0,sprice=30.0,bprice=25.0;
printf("Enter the number of locks and to exit the loop press -1\n");
scanf("%d",&locks);
while(locks!=-1)
{
printf("Enter the number of stocks and barrels");
scanf("%d%d",&stocks,&barrels);
tlocks=tlocks+locks;
tstocks=tstocks+stocks;
tbarrels=tbarrels+barrels;
printf("Enter the number of locks and to exit the loop press -1\n");
scanf("%d",&locks);
}
printf("Locks sold : %d\n",tlocks);
printf("Stocks sold : %d\n",tstocks);
printf("Barrels sold : %d\n",tbarrels);
lsales=lprice*tlocks;
ssales=sprice*tstocks;
bsales=bprice*tbarrels;
sales=lsales+ssales+bsales;
printf("Total sales : %f\n",sales);
if(sales>1800)
{

Department of ISE, SCEM Page 54


Software testing laboratory 2019-20
comm=0.10*1000.0;
comm=comm+0.15*800.0;
comm=comm+0.20*(sales-1800);
}
else if(sales>1000)
{
comm=0.10*1000.0;
comm=comm+0.15*(sales-1000);
}
else
comm=0.10*sales;
printf("Commission is %f \n",comm);
return 0;
}

9.5 TESTCASES
DATA FLOW TESTING: KEY STEPS
Given a code (program or pseudo-code).
1. Number the lines.
2. List the variables.
3. List occurrences & assign a category to each variable.
4. Identify du-pairs and their use (p- or c- ).
5. Define test cases, depending on the required coverage.

Variables Definition Nodes Usage Nodes


locks 13,22 14, 18
stocks 17 19
barrels 17 20
lockprice 6 27
stockprice 7 28
barrelprice 8 29
tlocks 9,18 24,18,27
tstocks 10,19 19,25,28
tbarrels 11,20 20,26,29
lsales 27 30
Bsales 29 30
ssales 28 30
commission 34,35,36,40,41,44 31,32,36,41,44
sales 30 35,36,41,45

Department of ISE, SCEM Page 55


Software testing laboratory 2019-20

Variables Used at DU Paths Definition Class


Defined at
locks 13 14 <13,14> yes
13 18 <13,18> yes
22 14 <22,23,14> yes
22 18 <22,23,14,15,16,17,18> yes
stocks 17 19 <17,18,19> yes
barrels 17 20 <17,18,19,20> yes
lockprice 6 27 <6,7,8,…..,27> yes
stockprice 7 28 <7,8,9,……,28> yes
barrelprice 8 29 <8,9,……,29> yes
tlocks 9 24 <9,10,11,……,24> no
9 18 <9,10,11,……,18> no
9 27 <9,10,11,……,27> no
18 18 <18> yes
18 24 <18,19,……..,24> yes
18 27 <18,19,……..,27> yes
tstocks 10 19 <10,11,……,19> yes
10 25 <10,11,……,25> yes
10 28 <10,11,……,28> yes
19 19 <19> yes
19 25 <19,……..,25> yes
19 28 <19,20……..,28> yes
tbarrels 11 20 <11,12,……,20> no
11 26 <11,12,……,26> yes
11 29 <11,12,……,29> yes
20 20 <20> yes
20 26 <20,21,……..,26> yes
20 29 <20,21,……..,29> yes
lsales 27 30 <27,28,…..…,30> yes
bsales 28 30 <28,29,30> yes
ssales 29 30 <29,30> yes
sales 30 31 <30,31> yes
30 32 <30,32> yes
30 36 <30,31,……,36> yes
30 38 <30,31,…….,38> yes
30 41 <30,31,…….,41> no
30 44 <30,31,…….,44> no
commission 34 35 <34,35> yes
34 36 <34,35,36> no
34 41 <34,35,41> infeasible
34 45 <34,35,….45> infeasible
35 35 <35> yes
35 36 <35,36> no
35 41 <35,36,…..41> yes

Department of ISE, SCEM Page 56


Software testing laboratory 2019-20
35 45 <35,36,….45> yes
36 35 <36,35> yes
36 36 <36> yes
36 41 <36,……,41> yes
36 45 <36,….,45> yes
40 35 invalid no
40 36 invalid no
40 41 <40,41> yes
40 45 <41,….,45> yes
41 35 invalid no
41 36 invalid no
41 41 <41> yes
41 45 <41,…..,45> yes
41 35 invalid no
44 36 invalid no
44 41 invalid no
44 45 <44,45> yes

9.6 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

9.7 SNAPSHOTS:

9.8PRE-EXPERIMENT & POST-EXPERIMENT QUESTIONS

8 What is an error?
9 What is the use of testing software?
10 What are the types of software testing?
11 What is boundary value analysis?
12 What is white box testing and list the types of white box testing?
13 What is black box testing? What are the different black box testing techniques?

Department of ISE, SCEM Page 57


Software testing laboratory 2019-20

EXPERIMENT No. 10: Binary Search-Basis Path Testing


10.1 Objective 10.5 Test cases
10.2 Requirement specification 10.6 Execution
10.3 Design 10.7 Snapshots
10.4 Program Code 10.8 Pre-experiment & Post-experiment questions

10.1 Objectives:
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.

10.2 REQUIREMENT SPECIFICATION


R1: The system should accept „n‟ number of elements and key element that is to be searched
among „n‟ elements..
R2: Check if the key element is present in the array and display the position if present
otherwise print unsuccessful search.

10.3 DESIGN
We use integer array as a data structure to store „n‟ number of elements. Iterative programming
technique is used.
ALGORITHM
Step 1: Input value of „n‟. Enter „n‟ integer numbers in array int mid;
Step 2: Initialize low = 0, high = n -1
Step 3: until ( low <= high ) do
mid = (low + high) / 2
if ( a[mid] == key )
then do Step 5
else if ( a[mid] > key )
then do

high = mid - 1
else
low = mid + 1
Step 4: Print unsuccessful search do step 6.
Step 5: Print Successful search. Element found at position mid+1.
Step 6: Stop.

Department of ISE, SIT Page 58


Software testing laboratory 2019-20

10.4 PROGRAM CODE:

#include<stdio.h>
void main()
{
int i,n,a[100],low,high,mid,key,flag=0;
printf("Enter the value of n\n");
scanf("%d",&n);
printf("Enter the elements : ");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
printf("Enter the key");
scanf("%d",&key);
low=0;
high=n-1;
while(low<=high)
{
mid=(low+high)/2;
if(key==a[mid])
{
flag=1;
break;
}
else if(key<a[mid])
high=mid-1;
else
low=mid+1;
}
if(flag==1)
printf("Key found at position %d",mid+1);
else
printf("key not found");
}

10.5 TESTCASES
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 the cyclomatic complexity.
3. Select a basis set of paths.
4. Generate test cases for each of these paths.

Department of ISE, SIT Page 59


Software testing laboratory 2019-20

The program graph and DD-path graph has to be drawn in observation.


Complexity of a graph is given
By: V(G) = e – n + 2p.
Number of edges (e) =20
Number of nodes (n)=16
Number of connected regions= 1=20-16+2(1) =6

Program
graph node DD path name Case description
1 first 1
2-6 A 5
7 B 3
8 C 4
9-12 D 5
13 E 3
14-15 F 5
16 G 3
17-20 H 5
21 I 3
22 J 4
23-24 K 5
25 L 3
26 M 3
27 N 4
28-29 O 5
30 P 2

DERIVING TEST CASES USING BASIS PATH TESTING


The last step is to devise test cases for the basis paths.
TEST CASES
TC Test Case Value array Expected Actual
Key Status
ID Description of ‘n‘ elements Output Output
1 First-A-(B-C)*- 5 2 4 6 8 10 6
3
D-E-F-G-H-M-N-
P
2 First-A-(B-C)*-D- 5 13579 10
Key Not
E-F-G-I-K-L-E- Found
M-O-P
Department of ISE, SIT Page 60
Software testing laboratory 2019-20
Key Not
3 First-A-(B-C)*- 0 -- 2
Found
D-E-M-O-P
4 First-A-(B-C)*-D- 5 12345 2
1
E-F-G-I-J-E-F-G-
H-M-N-P
5 First-A-(B-C)*-D- 5 12345 4
3
E-F-G-I-K-L-E-F-
G-H-M-N-P
10.6 EXECUTION :
Execute the program against the designed test cases and complete the table for Actual output
column and status column.
Test Report:
10.6.1 No of TC‟s Executed:
10.6.2 No of Defects Raised:
10.6.3 No of TC‟s Pass:
10.6.4 No of TC‟s Failed:
10.7 SNAPSHOTS:

10.8PRE-EXPERIMENT & POST-EXPERIMENT QUESTIONS

1. What is data flow testing?


2. What is defined node?
3. What is usage node?
4. What is basis path testing?

Department of ISE, SIT Page 61


Software testing laboratory 2019-20
EXPERIMENT No. 11: Quick Sort-Basis Path Testing
11.1 Objective 11.5 Test cases
11.2 Requirement specification 11.6 Execution
11.3 Design 11.7 Snapshots
11.4 Program Code 11.8 Pre-experiment & Post-experiment questions

11.1 Objectives:

Design, develop, code and run the program in any suitable language to implement the
quicksort algorithm. Determine the basis paths and using them derive different test
cases, execute these test cases and discuss the test results.
11.2 REQUIREMENTS SPECIFICATION:

R1: The system should accept “n‟ number of elements and key element that is to be searched
among “n‟ elements.
R2: Check if the key element is present in the array and display the position if present
otherwise print unsuccessful search.

11.3 DESIGN:
We use integer array as a data structure to store „n‟ number of elements. Iterative programming
technique is used.

11.4 PROGRAM CODE:


// An iterative implementation of quick sort
#include<stdio.h>
21 void quicksort(int x[10],int first,int last)
22 {
23 int temp,pivot,i,j;
24 if(first<last)
25 {
26 pivot=first;
27 i=first;
28 j=last;
29 while(i<j)
30 {
31 while(x[i]<=x[pivot] && i<last)
32 i++;
33 while(x[j]>x[pivot])
34 j--;
35 if(i<j)
36 {

Department of ISE, SIT Page 62


Software testing laboratory 2019-20
37 temp=x[i];
38 x[i]=x[j];
39 x[j]=temp;
40 }
41 }
42 temp=x[pivot];
43 x[pivot]=x[j];
44 x[j]=temp;
45 quicksort(x,first,j-1);
46 quicksort(x,j+1,last);
47 }
48 }
1 int main()
2{
3 int a[20],i,key,n;
4 printf("enter the size of the array");
5 scanf("%d",&n);
6 if(n>0)
7{
8 printf("enter the elements of the array");
9 for(i=0;i<n;i++)
10 scanf("%d",&a[i]);
11 quicksort(a,0,n-1);
12 printf("the elements in the sorted array is:\n");
13 for(i=0;i<n;i++)
14 printf("%d\t",a[i]);
15 }
16 else
17 {
18 printf("size of array is invalid\n");
19 }
20 }

Cyclomatic complexity
The Cyclomatic complexity of the graph given by the equation
V(G)=e-n+2p
Where e is number of edges ,n is the number of nodes, and p is the number of connected
regions.
No. of edges e =27
No. of nodes n =21
number of connected regions p=1
V(G)=e-n+2p
=27-21+2(1)=8

Department of ISE, SIT Page 63


Software testing laboratory 2019-20
Program
graph nodes DD path name
1-5 A
6 B
7-8 C
9 D
10 E
11 F
21-23 G
24 H
25-28 I
29 J
30,31 K
32 L
33 M
34 N
35 O
36-39 P
40-41 Q
42-44 R
45 S
46 T
47 U
48 V
12 W
13 X
14 Y
15 Z
16-19 a
20 b

9.5 TESTCASES

TC Test Case Value array Expected Actual


Status
ID Description of ‘n‘ elements Output Output
1 Testing for path 0 --
Size of array
P1 is invalid
2 Testing for path P2 1 3
3
3 Testing for path P3 2 5,4
5,4
4 Testing for path P4 3 3,1,2
3,4, 5

Department of ISE, SIT Page 64


Software testing laboratory 2019-20
1,2,3,4, 5
5 Testing for path P5 5 1,2,3,4,5
1,2,3,4, 5
6 Testing for path P6 5 5,4,3,2,1
1,2,3,4, 5
7 Testing for path P7 1,4,3,2,5
1,2,3,4, 5
8 Testing for path P8 5 5,2,3,1,4

11.6 EXECUTION
Compile the program and enter inputs Test above table array elements for test cases.
Test Report:
11.6.1 No of TC‟s Executed:
11.6.2 No of Defects Raised:
11.6.3 No of TC‟s Pass:
11.6.4 No of TC‟s Failed:

11.7 SNAPSHOTS:

Department of ISE, SIT Page 65


Software testing laboratory 2019-20
11.8PRE-EXPERIMENT & POST-EXPERIMENT QUESTIONS

1 What is an error?
2 Explain quicksort algorithm
3 What is basis path testing
4 What is DD path
5 What is program graph

Department of ISE, SIT Page 66


Software testing laboratory 2019-20
EXPERIMENT No. 12: Letter Grading-Basis Path Testing
12.1 Objective 12.5 Test cases
12.2 Requirement specification 12.6 Execution
12.3 Design 12.7 Snapshots
12.4 Program Code 12.8 Pre-experiment & Post-experiment questions

12.1 Objectives:

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
12.2 REQUIREMENTS SPECIFICATION:
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 compute the average of marks scored and percentage
of the same and depending on percentage display the grade.

12.3DESIGN:
Structural representations of program statement, mathematical notations of the basis
has attracted.
Structural testing involves following steps:
13.4.1 Complete the program graph
13.4.2 Considering the program graph, draw the DD path graph
13.4.3 Calculate cyclomatic complexity
13.4.4 Select basis set of path
13.4.5 Generate the test case for each of the path.

12.4 PROGRAM CODE:


#include<stdio.h>
void main()
{
float per;
char grade;
printf("Enter the between 1 and 100\n");
scanf("%f",&per);
if(per>0&&per<=100)
67
Department of Information Science and Engineering, SCEM, Mangaluru.
{
Software testing laboratory 2019-20
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("Excellent\n");
break;
case 'B':printf("Very Good\n");
break;
case 'C':printf("Good\n");
break;
case 'D':printf("Above average\n");
break;
case 'E':printf("Staisfactory\n");
break;
}
printf("The percentage grade is %c\n",grade);
}
else
printf("Invalid Input");
}

12.5 TESTCASES:

Program
graph nodes DD path name Case description
1 first 1
2-6 A 5
7 B 3
8 C 4

68
Department of Information Science and Engineering, SCEM, Mangaluru.
9 D 3
Software testing laboratory 2019-20
10 E 4
11 F 3
12 G 4
13 H 3
14 I 4
15 J 3
16 K 4
17-18 L 5
19 M 3
20 N 3
21-22 O 5
23-24 P 5
25-26 Q 5
27-28 R 5
29-30 S 5
31 T 3
32-33 U 5
34-35 V 5
36 W 2

TC Test Case Inp Expected Actual


ut Status
ID Description Output Output
Invalid Input
P1 First-A-B-V-W 115
P2 First-A-B-C-D-E-M- 95
Excellent
N-O-T-U-W
Very Good
P3 First-A-B-C-D-E-G- 85
M-N-P-T-U-W
Good
P4 First-A-B-C-D-F-H- 75
I-M-N-Q-T-U-W
P5 First-A-B-C-D-F-H- 65
Above Average
J-K-L-M-N-R-T-U-
W
P6 First-A-B-C-D-F-H- 50
Satisfactory
J-L-M-N-S-T-U-W

12.6EXECUTION
69
Department of Information Science and Engineering, SCEM, Mangaluru.
Software testing laboratory 2019-20

Execute the program and test the test cases in above Tables against program
and complete the table for Actual output column and Status column

12.7 SNAPSHOTS

12.8PRE-EXPERIMENT & POST-EXPERIMENT QUESTIONS

1. What is Basis path testing?


2. What is the use of testing software?
3. What are the types of software testing?

70
Department of Information Science and Engineering, SCEM, Mangaluru.

You might also like