STM Practice Sessions
1. Boundary Value Analysis
Question
X Company has a following unique rules for selection of employees.
• The employee age should be >=18 and <=56
• Employee should have underwent minimum of 16 years of
education and maximum 25 years of education
• Employee should have scored more than 60 marks and lesser than
90 marks in his last degree
• For the given parameters identify boundaries in table format
• Calculate the tests for
– BVA
– Robust BVA
– Worst case BVA
– Robust worst case BVA
• Write test cases for Robust BVA
Answer A
Boundary Age Education Marks
LB 18 16 61
LB+1 19 17 62
MV 35 20 75
UB-1 55 24 88
UB 56 25 89
LB-1 17 15 60
UB+1 57 26 90
Answer B
No of tests cases
BVA= 4(3)+1=13
Robust BVA=6(3)+1=19
Worst case BVA=5^3=125
Robust worst case BVA=7^3=343
Answer C:Robust BVA
Test Case # Age Education Mark
1 35 20 75
2 18 20 75
3 19 20 75
4 55 20 75
5 56 20 75
6 17 20 75
7 57 20 75
8 35 16 75
9 35 17 75
10 35 24 75
11 35 25 75
12 35 15 75
13 35 26 75
14 35 20 61
15 35 20 62
16 35 20 88
17 35 20 89
18 35 20 60
19 35 20 90
2. White Box testing- Graph
• Identify the cyclomatic complexity of the
Graph
• Indentify Number of unique paths
Answer:
edges and node method
e = 22, n = 15
v = 22 -15 +2
v=9
P1=1-2-4-6-7-8-9-11-13-14-15
P2=1-2-3-6-7-8-9-11-13-14-15
P3=1-2-5-6-7-8-9-11-13-14-15
P4=1-2-5-2-4-6-7-8-9-11-13-14-15
P5=1-2-4-6-7-2-4-6-7-8-9-11-13-14-15
P6=1-2-4-6-7-8-9-11-13-14-9-11-13-14-15
P7=1-2-4-6-7-8-9-10-13-14-15
P8=1-2-4-6-7-8-9-10-12-13-14-15
P9=1-2-4-6-7-8-9-10-12-9-11-13-14-15
3. White Box testing
ReturnAverage() /* Design Test cases ..*/
public static double ReturnAverage(int value[], int AS, int MIN, int MAX)
{
/* Function: ReturnAverage Computes the average of all those numbers in the input array in
the positive range [MIN, MAX]. The maximum size of the array is AS. But, the array size
could be smaller than AS in which case the end of input is represented by -999. */
int i, ti, tv, sum;
double av;
i = 0; ti = 0; tv = 0; sum = 0;
while (ti < AS && value[i] != -999) {
ti++;
if (value[i] >= MIN && value[i] <= MAX) {
tv++;
sum = sum + value[i];
}
i++;
}
if (tv > 0)
av = (double)sum/tv;
else
av = (double) -999;
return (av);
}
Decision Table- Exercise
• Company X sells merchandise to wholesale and retail outlets.
Wholesale customers receive a two percent discount on all
orders. The company also encourages both wholesale and
retail customers to pay cash on delivery by offering a two
percent discount for this method of payment. Another two
percent discount is given on orders of 50 or more units. Each
column represents a certain type of order.
Solution
Decision Table- 2
A pizza company has launched a new restaurant and developed a software
to take care of their billing needs. Following are the menu they have in their
restaurant
The customers can be pure vegetarian, mixed (veg+non veg) consumer
If the value of bill is more than Rs 500 in an order the customer is eligible
for a free desert
Customer can order 1 pizza in a bill, All prices includes taxes
The software should give the bill value and whether the customer is
eligible for free desert
Pizza name type Personal Medium Family
Price Price price
Zesty chicken Non veg 85 170 320
Veg Supreme Veg 205 340 530
Chicken italia Non Veg 205 340 530
Solution sample
Number of
parameter values 1 2 3
Values
customer type Veg,Mixed 2 veg veg veg
Pizza order vsup,fchic,zchic 3 zchic zchic zchic
personal,medium,fa
size 3 personal medium family
mily
4. Data Flow Testing- Design DU Table
1: Input(x)
2: Input(y)
3: if x < 10 then
4: y := y + 2
5: else
6: x:= x+1
7: end if
8: if y > 20 then
9: y := y +1;
10: end if
11: Write(x,y) Variable x
12: end De Us
f e
1
2
3
Answer : DU table for x & y
Variable x Variable y
De Us De Us
f e f e
1 1 3 1 2 8
2 1 11 2 2 11
3 6 11 3 4 8
4 4 11
5 9 11
5. Data Flow Testing: Design DU table
Variable: r0, r1, r2, r3, a[]
1 void sort(int n, int a[])
{ int r0, r1, r2, r3;
2 r3 = 0;
3 r1 = 0 ;
4 while (r1 <n)
5 { r0=a[r1];
6 r2=r1+1;
7 r3=r1;
8 while (r2<n) {
9 if (a[r2]>r0) {
10 r0=a[r2];
11 r3=r2;
};
12 r2++;
};
13 r2=a[r1];
14 a[r1]=r0;
15 a[r3]=r2;
16 r1++;
};
};
Answer
Variable r0 Variable r3
Def Use Def Use
1 5 9 5 7 15
2 5 14 6 11 15
3 10 9
4 10 14
Variable r1 Variable r2
Def Use Def Use
7 3 4 21 6 8
8 3 5 22 6 9
9 3 6 23 6 10
10 3 7 24 6 11
11 3 13 25 6 12
12 3 14 26 12 8
13 3 16 27 12 9
14 16 4 28 12 10
15 16 5 29 12 11
16 16 6 30 12 12
17 16 7 31 13 15
18 16 13
19 16 14
20 16 16
Variable a[] Variable n
Def Use Def Use
32 1 5 40 1 4
33 1 9 41 1 8
34 1 10
35 1 13
36 15 5
37 15 9
38 15 10
39 15 13
6. Exercise: Design Test cases for the following problem
(Decision Table-Cause & Effect)
Indian income tax department has changed the tax policy
and released a new application for you to test
Following are the business rules:
No tax till 1,50,0000
10 per cent for 150,000 to 300,000,
20 per cent for 300,001 to 500,000 and
30 per cent for above 500,001
For women, the non taxable limit is Rs 1.80 lakh
For senior citizens, non taxable limit is Rs 2.25 lakh.
Solution sample
IS Male Y,N Y Y Y Y Y
Senior
Citizen Y,N Y Y Y Y Y
Salary 150K,180K,225K,300
Range K,500K 150k 180k 225k 300k 500k
20
Expected
result
No tax
10%
20%
30%
Special value testing?
[Link] really helps
[Link] done by the customer or user
[Link] measurement
[Link] intuitive
[Link] repeatable
[Link], very effective
Advantages:
[Link] mathematical (or algorithmic) calculations
[Link] Case situations (similar to robustness)
[Link] situations from past experience
4.“Second guess” the likely implementation
Slice based Testing
The idea of slices is to separate a program
into components that have some useful
meaning
Slice based testing
• Given a program P, and a program graph G(P)
in which statements and statement fragments
are numbered, and a set V of variables in P,
the slice on the variable set V at statement
fragment n, written S(V,n), is the set node
numbers of all statement fragments in P prior
to n that contribute to the values of variables
in V at statement fragment n
Number of Test Coverage Items
high
low
Sophistication
DD- Basis DU- Slice
Path Path Path
Effort to Identify Test Coverage Items
high
low
Sophistication
DD- Basis DU-Path Slice
Path Path