Software Testing – Practice
(Answer)
[1] Black Box Testing Techniques
(C) 2023 – Pham Nhat Duy – Nguyen Ngoc Qui
1
[Exercise 1]
Boundary value analysis technique (1/ value analy value analysis technique (1/sis technique (1/
2)
Suppose y value analysis technique (1/ou are testing a program that a prog a program that ram that that
calculates the cost of a hotel stay a hotel stay value analysis technique (1/. The co The co
st is calculated based on the num that ber of a hotel stay d
ay value analysis technique (1/s stay value analysis technique (1/ed and the room that rate. The co The room that
rate is determ that ined by value analysis technique (1/ the ty value analysis technique (1/pe of a hotel stay room that (s
ing a program that le or double) and the season (hig a program that h or l
ow). The co The cost is calculated using a program that the f a hotel stayollo
wing a program that f a hotel stayorm that ula:
cost = number of days * room rate num that ber of a hotel stay day value analysis technique (1/s * room rate room that rate
(C) 2023 – Pham Nhat Duy – Nguyen Ngoc Qui
2
[Exercise 1]
Boundary value analysis technique (1/ value analy value analysis technique (1/sis technique (2/
2)
The room that rates are as f a hotel stayollows:
Sing a program that le room that : $50 per night per nig a program that ht in the low seaso
n, and and $10 per night 0 per night per nig a program that ht in the hig a program that h season. The co
Double room that : $75 per nig a program that ht in the low seaso
n, and and $150 per night per nig a program that ht in the hig a program that h season. The co
Using a program that the boundary value analysis technique (1/ value analy value analysis technique (1/sis techni
que, and identif a hotel stayy value analysis technique (1/ the test cases that would b
e the m that ost effective in testing a program that this prog a program that r
am that . The co
(C) 2023 – Pham Nhat Duy – Nguyen Ngoc Qui
3
Exercise 1 – Answer (1/3)
First, and we need to identif a hotel stayy value analysis technique (1/ the boundaries
of a hotel stay the input rang a program that es
Num that ber of a hotel stay day value analysis technique (1/s stay value analysis technique (1/ed: Min: 1, and Max: Non
e. The co
Room that ty value analysis technique (1/pe: Sing a program that le, and Double. The co
Season: Low, and Hig a program that h. The co
Because the rang a program that e ty value analysis technique (1/pes of a hotel stay the inputs ar
e not the sam that e, and so we can have several a
ccepted answers. The co
(C) 2023 – Pham Nhat Duy – Nguyen Ngoc Qui
4
Exercise 1 – Answer (2/3)
Answer 1:
(C) 2023 – Pham Nhat Duy – Nguyen Ngoc Qui
5
Exercise 1 – Answer (3/3)
Answer 2 (And other answers: see excel
file)
(C) 2023 – Pham Nhat Duy – Nguyen Ngoc Qui
6
Note: n is the number of variables.
BUT WHY? (1/4)
In f a hotel stayact, and we have m that any value analysis technique (1/ ty value analysis technique (1/pes of a hotel stay Boundary value analysis technique (1/ v
alue analy value analysis technique (1/sis techniques:
Standard BVA: Maxim that um that num that ber of a hotel stay test cases:
4n+1
Robustness: Maxim that um that num that ber of a hotel stay test cases: 6
n+1
Worst-case: Maxim that um that num that ber test cases: 5n
Robust worst-case: Maxim that um that num that ber of a hotel stay test c
ases: 7n
…
(C) 2023 – Pham Nhat Duy – Nguyen Ngoc Qui
7
In standard BVA, and the test cases will be base
BUT WHY? (2/4)
Why value analysis technique (1/ is 4n + 1?
As we know, and the test cases will be based
on 5 VALID values: [m that in, and m that in+, and nom that inal, and
m that ax-, and m that ax]
Total test cases = number of days * room rate
(Num that ber of a hotel stay variables * room rate Num that ber of a hotel stay testing a program that p
oints without nom that inal ) + 1 (f a hotel stayor Nom that inal)
= number of days * room rate 4n + 1
(C) 2023 – Pham Nhat Duy – Nguyen Ngoc Qui
8
Ex1: In theory, 4n+1 = 4*3+1 = 13
BUT WHY? (3/4)
However, and in exercise 1, and the rang a program that e ty value analysis technique (1/pes o
f a hotel stay the inputs are not the sam that e:
•
•
Num that ber of a hotel stay day value analysis technique (1/s stay value analysis technique (1/ed: Min: 1, and Max: None
Room that ty value analysis technique (1/pe: Sing a program that le, and Double (No m that in/m that ax/nom that
inal)
Number
of daysLow, and
stayed:
Season:
Hig a program that h (No m that in/m that ax/nom that inal)
Boundary value analysis technique (1//Max values according a program that to
real-lif a hotel staye
Room type/season: Loop
throug a program that h all or select several
values as long a program that as the num that ber of a hotel stay
test cases <= number of days * room rate MAXIMUM
(C) 2023 – Pham Nhat Duy – Nguyen Ngoc Qui
9
BUT WHY? (4/4)
Answer 2: Num that . The co of a hotel stay test cases = number of days * room rate 12 < Max
= number of days * room rate 13
(C) 2023 – Pham Nhat Duy – Nguyen Ngoc Qui
10
Example for Standard BVA (1/4)
Suppose we have three variables X, and Y, and an
d Z. The co
X: 0 per night 10 per night 0 per night . The co
Y: 20 per night 60 per night . The co
Z: 80 per night 10 per night 0 per night . The co
Using a program that standard BVA to list the test cases
f a hotel stayor this prog a program that ram that ?
(C) 2023 – Pham Nhat Duy – Nguyen Ngoc Qui
11
Example for Standard BVA (2/4)
First, and finding a program that the valid values f a hotel stayor each
variable
X
Y
Z
Min
0
20
80
Min+
1
21
81
Nominal
50
40
90
Max-
99
59
99
Max
100
60
100
(C) 2023 – Pham Nhat Duy – Nguyen Ngoc Qui
12
Example for Standard BVA (3/4)
Next
We will fix nom that inal values of a hotel stay X, and Y and
m that ake a com that bination with each value of a hotel stay
Z
Do the sam that e f a hotel stayor the pairs Y, and Z and X, and Z
(C) 2023 – Pham Nhat Duy – Nguyen Ngoc Qui
13
Example for Standard BVA (4/4)
Result
(C) 2023 – Pham Nhat Duy – Nguyen Ngoc Qui
14
[Exercise 2]
Orthog a program that onal Array value analysis technique (1/
Given 3 variables:
A – 2 values (A1, A2)
B – 3 values (B1, B2, B3)
C – 3 values (C1, C2, C3)
Using a program that the Orthog a program that onal Array value analysis technique (1/ Testing a program that
technique, and identif a hotel stayy value analysis technique (1/ the test cases f a hotel stayor
this prog a program that ram that . The co
(C) 2023 – Pham Nhat Duy – Nguyen Ngoc Qui
15
Exercise 2 – Answer (1/2)
3 variables:
A – 2 values (A1, A2)
B – 3 values (B1, B2, B3)
C – 3 values (C1, C2, C3)
3 Factors & 3
Levels
Array value analysis technique (1/ Ty value analysis technique (1/pe L9(34)
NOTE: L4(23) and L8(27) cannot be chosen because
they have only 2 possible values (levels)
(C) 2023 – Pham Nhat Duy – Nguyen Ngoc Qui
16
Exercise 2 – Answer (2/2)
Result
Empty Orthogonal Array cell Cycle values in
17
(C) 2023 – Phamthem.
Nhat Duy – Nguyen Ngoc Qui