Name : P.
Ragavendhar
Reg No : 15MIS0087
Advanced Software Testing Lab
Lab : L43+L44
A program takes as input a string (5-20 characters) and a single character and checks
whether that single character is present in the string or not. Implement the given
program using any programming language and design test cases using BVA, robust
testing and worst-case testing method
Program :
def find (string , character) :
if (len(string)>=5 and len(string)< 20) :
print ("The string have valid Character")
if (string.count(character) > 0) :
print ("the Character is present in the string")
else :
print ("the Character is not present in the string")
else :
print ("the string have invalid Character")
BOUNDARY VALUE CHECKING :
Number of test case = 4n+1 (1 variable) = 5
Test TEST INPUT Expected result Actual Result Status
case no String char
1 A min (abcde) A Single character Present Single character Pass
Present
2 A min+(abcdeg) A Single character Present Single character Fail
not Present
3 A max- A Single character not Single character Pass
(abcdefgijklmnopqrs) Present not Present
4 A max A Single character Present Single character Fail
(abcdefghijklmnopqrst) not Present
5 A nom (abcdefghijklm) A Single character Present Single character Pass
Present
ROBUSTNESS :
Number of test cases = 6n+1 (1 variable) =7
Test TEST INPUT Expected result Actual Result Status
case String A char
no
1 A min (abcde) A Single character Present Single character Pass
Present
2 A min+(abcdeg) A Single character Present Single character Fail
not Present
3 A max- A Single character not Single character pass
(abcdefgijklmnopqrs) Present not Present
4 A max A Single character Present Single character Fail
(abcdefghijklmnopfst) not Present
5 A nom (abcdefghijklm) A Single character Present Single character pass
Present
6 A min- (abcd) A Invalid character Single character Fail
not present
7 A A Invalid character Single character Fail
max+(abcdefghijklmno present
pqrstu)
WORST CASE :
Number of test cases = 5^n =5^1 = 5
Test TEST INPUT Expected result Actual Result Status
case no String A Char
1 A min (abcde) A Single character Present Single character Pass
Present
2 A min+(abcdeg) A Single character Present Single character Fail
not Present
3 A max- A Single character not Single character Pass
(abcdefgijklmnopqrs) Present not Present
4 A max A Single character Present Single character Fail
(abcdefghijklmnopqrst) not Present
5 A nom (abcdefghijklm) A Single character Present Single character Pass
Present
Output :
Consider this situation. We are writing a module for a human resources system that
decides how we should process employment applications based on a person's age. Our
organization's rules are:
Equivalence Class of Hire
* 0-16 don’t hire
* 16-18 can hire on a part-time basis only
* 18-55 can hire as a full-time employee
* 55-99 can hire for advisory committee only.
Develop the program for these rules and design the test case using Equivalence class
partitioning.
Program :
def Class_Of_Hire(x) :
if (x > 0 and x <= 99) :
if (x > 0 and x <= 16) :
print (" don't hire ")
elif (x > 16 and x <= 18) :
print (" Hire on Part Time Basis only ")
elif (x > 18 and x <= 55) :
print (" Hire as a Full Time Employee ")
else :
print (" Hire for advisory committee only ")
else :
print (" Not Suitable Age ")
Equivalence class partitioning
STEP 1
Condition 1: Age is between 0-16 don’t hire
Condition 2: Age is between 16-18 part-time basis only
Condition 3: Age is between 18-55 Full time employee
Condition 4: Age is between 55-99 Advisory committee only
STEP 2
Condition 1: Age is between 0-16 don’t hire
EC1 - Age is 0-16 (9) valid
EC2 - Age is less than 0 (-1) invalid
EC3 – Age is greater than 16 (18) invalid
Condition 2: Age is between 16-18 part-time basis only
EC4 - Age is 16-18 (17) valid
EC5 - Age is less than 16 (15) invalid
EC6 – Age is greater than 18 (19) invalid
Condition 3: Age is between 18-55 Full time employee
EC7 - Age is 18-55 (28) valid
EC8 - Age is less than 18 (17) invalid
EC9 – Age is greater than 55 (56) invalid
Condition 4: Age is between 55-99 Advisory committee only
EC10 - Age is 55-99 (58) valid
EC11 - Age is less than 55 (54) invalid
EC12 – Age is greater than 99 (100) invalid
STEP 3
EC TABLE
Conditions Valid EC Invalid EC
1 EC1 EC2,EC3
2 EC4 EC5,EC6
3 EC7 EC8,EC9
4 EC10 EC11,EC12
STEP 4
TEST CASE TABLE
Number of test case = Number of Equivalence classes (EC’s) = 12
TC No Test ER AR Status EC
input Coverage
Age
1 9 Don’t hire Don’t hire Pass EC1
2 -1 Invalid Age Invalid Age Pass EC2
3 18 Invalid age Part time Fail EC3,EC4
basis only
4 17 Part-time basis Part time Pass EC4
only basis only
5 15 Invalid age Don’t hire Fail EC5,EC1
6 19 Invalid age Full time Fail EC6,EC7
Employee
7 28 Full time Full time Pass EC7
Employee Employee
8 17 Invalid age Part-time Fail EC8,EC4
basis only
9 56 Invalid age Advisory Fail EC9,EC10
committee
only
10 58 Advisory Advisory Pass EC10
committee committee
only
11 54 Invalid age Full time Fail EC11,EC7
Employee
12 100 Invalid age Invalid age Pass EC12,EC2
STEP 5
REMOVE DUPLICATES IN TEST CASE TABLE
Number of test cases = 5
Test case no Test input Expected Actual result Status EC coverage
Age result
1 15 Don’t hire Don’t hire Pass EC1, EC5
2 17 Part time Part time Pass EC4, EC3
basis only basis only
3 28 Full time Full time Pass EC7, EC6,
employee employee EC11
4 58 Advisory Advisory Pass EC10, EC9
committee committee
only only
5 102 Invalid age Invalid age Pass EC2, EC12
Output :
A mobile phone service provider uses a program that computes the monthly bill of
customers as follows:
Minimum Rs. 300 for up to 120 calls
Plus Rs.1 per call for the next 70 calls
Plus Rs. 0.80 per call for the next 50 calls
Plus Rs. 0.40 per call for call beyond 240 calls
Write a program and implement the above application. Design test cases for this program
using equivalence class testing technique and test the given application.
Program :
def call (x) :
if (x > 0 and x <= 120) :
print ("Minimum amount for upto 120 calls :" , 300)
if (x > 120 and x <= 190) :
a = ( x * 1 ) + 300 - 120
print (a)
if (x > 190 and x <= 240) :
b = ( x * 0.80) - (190 * 0.80) + 300 + ( 70 * 1)
print (b)
if (x > 240) :
c = (x * 0.40) - (240 * 0.40) + 300 + 70 + (50 * 0.80)
print (c)
Equivalence class partitioning
Step 1: Conditions
Condition 1: If no of calls is less than or equal to 120 : Rs.300 (Minimum Charge)
Condition 2: If no of calls is >120 and <=190: Plus Rs.1 for exceeded calls alone.
Condition 3: If no of calls is >190 and <=240: Plus Rs.0.80 for exceeded calls alone.
Condition 4: If no of calls is >240 and : Plus Rs. 0.40 for exceeded calls alone.
Step 2: Mapping conditions with ECP Rules.
Condition 1:
EC1 – no of calls b/w 1-120
EC2 – no of calls lesser than 1
EC3 – no of calls greater than 120
Condition 2:
EC4 – no of calls b/w 121 - 190
EC5 – no of calls lesser than 121
EC6 – no of calls greater than 190
Condition 3:
EC7 – no of calls b/w 191- 240
EC8 – no of calls lesser than 191
EC9 – no of calls greater than 240
Condition 4:
EC10 – no of calls greater than 240
EC11 – no of calls is lesser than 240
Step 3: EC Table:
Condition Valid Invalid
1 EC1 EC2, EC3
2 EC4 EC5, EC6
3 EC7 EC8, EC9
4 EC10 EC11
Step 4:
TEST CASE TABLE
No. of Test Cases = No. of EC’s = 11
TC_No Test Input Expected Actual Status EC
No of Calls Result Result Coverage
1 100 300 300 Pass EC1
2 -1 Invalid Input Invalid Input Pass EC2
3 121 301 301 Pass EC3
4 130 330 330 Pass EC4
5 120 300 300.80 Fail EC5
6 191 370.80 370.80 Pass EC6
7 192 371.60 371.60 Pass EC7
8 190 370 370 Pass EC8
9 241 410.40 410 Fail EC9
10 242 410.80 410.40 Fail EC10
11 240 410 410 Pass EC11
Step 5:
REMOVE DUPLICATES IN TEST CASE TABLE
Number of test cases = 5
TC_No Test Input Expected Actual Status EC Coverage
Age Result Result
1 100 300 300 Pass EC1,EC5
2 -1 Invalid Input Invalid Pass EC2
Input
3 121 301 301 Pass EC3,EC4,EC8
4 191 370.80 370.80 Pass EC6,EC7,EC11
5 241 410.40 410 Fail EC9,EC10
Output :
An electricity board charges the following rates for the use of electricity:
For the first 200 units; 80 P per unit
For the next 100 units; 90 P per unit
Beyond 300 units; Rs. 1 per unit
All users are charged a minimum of Rs. 100 as meter charge.If the total amount is more
than Rs. 400, then an additional surcharge of 15% of total amount is charged.Write a
program to read the names of users and number of units consumed and printout the
charges with names. Design the Test case for this scenarios using suitable Black box
testing technique.
Program :
def read (x) :
if (x > 0 and x <= 200) :
a = x * 0.80
print ("electricity charge :" , a+100)
if (x > 200 and x <= 300) :
b = ( x * 0.90 ) - (200 * 0.90)
c = 200 * 0.80
print ("electricity charge :" , b + c + 100)
if (x > 300) :
d = ( x * 1) - (200 * 1) - (100 * 1)
e = 200 * 0.80
f = 100 * 0.90
amnt = d+e+f+100
print ("electricity charge :" , amnt)
if (amnt > 400) :
additional = amnt * 0.15
print ("Additional amount :" , additional)
print ("Total electricity charge :" ,amnt + additional)
Equivalence class partitioning
STEP 1
Condition 1: Units is between 0-200 charge is 80 paise per unit
Condition 2: Units is between 201-300 charge is 90 paise per unit
Condition 3: Units above 300 charge is Rs.1 per unit
STEP 2
Condition 1: Units is between 0-200 charge is 80 paise per unit
EC1 – Units is 0-200 (100) valid
EC2 – Units is less than 0 (-1) invalid
EC3 – Units is greater than 200 (220) invalid
Condition 2: Units is between 201-300 charge is 90 paise per unit
EC4 – Units is 201-300 (250) valid
EC5 - Units is less than 201 (150) invalid
EC6 – Units is greater than 300 (350) invalid
Condition 3: Units above 300 charge is Rs.1 per unit
EC7 - Units is above 300 (350) valid
EC8 - Units is less than 300 (250) invalid
STEP 3
EC TABLE
Conditions Valid EC Invalid EC
1 EC1 EC2, EC3
2 EC4 EC5, EC6
3 EC7 EC8
STEP 4
TEST CASE TABLE
Number of test case = Number of Equivalence classes (EC’s) = 8
Test case id Test Expected result Actual Status EC
input result Coverage
Units
1 100 180 180 Pass EC1
2 -1 Invalid Invalid Pass EC2
3 220 278 278 pass EC3
4 250 305 305 Pass EC4
5 150 220 220 Pass EC5
6 350 460 460 Pass EC6
7 350 460 460 Pass EC7
8 250 305 305 Pass EC8
STEP 5
REMOVE DUPLICATES IN TEST CASE TABLE
Number of test cases = 5
Test case Test input Expected Actual Status EC coverage
no Age result result
1 100 180 180 Pass EC1, EC5
2 250 305 305 Pass EC4, EC3,
EC8
3 350 460 460 Pass EC7, EC6
4 -1 Invalid Invalid Pass EC2
Output :