Вы находитесь на странице: 1из 22

SS ZG 552

Software Testing
Methodologies
BITS Pilani Dr. Ritu Arora
rituarora@pilani.bits-pilani.ac.in
Pilani|Dubai|Goa|Hyderabad
Example – BVA –
Image Processing
An image can be represented in the form of pixels. Each
pixel has a [RGB] value which represents the Red,
Green and Blue color components of the pixel. Each of
the [RGB] values lie in the range 0-255 (end points
included). A program takes the [RGB] value of a pixel
and returns the most dominant color of the pixel (which
ever component has the highest value is the dominant
color).

a) Calculate the number of test cases – Normal BVA,


Robust BVA, Worst case BVA and Robust worst case
BVA.

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Example – BVA –
Image Processing
For BVA :
Total number of test cases: 4 n + 1 = 4 * 3 + 1 = 13

For Robust BVA :


Total number of test cases: 6 n + 1 = 6 * 3 + 1 = 19

For Worst Case BVA :


Total number of test cases: 5^n= 5 * 5 * 5 = 125

For Robust Worst Case BVA :


Total number of test cases: 7^n= 7 * 7 * 7 = 343

b) Write all the test cases for Robust BVA for the pixel program.

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Example – BVA –
Image Processing
Test Case # Red Green Blue Expected Output
1 -1 100 200 Invalid
2 0 100 200 Blue
3 1 100 200 Blue
4 100 100 200 Blue
5 254 100 200 Red
6 255 100 200 Red
7 256 100 200 Invalid
8 100 -1 200 Invalid
9 100 0 200 Blue
10 100 1 200 Blue
11 100 254 200 Green
12 100 255 200 Green
13 100 256 200 Invalid
14 100 200 -1 Invalid
15 100 200 0 Green
16 100 200 1 Green
17 100 200 254 Blue
18 100 200 255 Blue
19 100 200 256 Invalid
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
BITS Pilani
Pilani|Dubai|Goa|Hyderabad

Specification-based Testing:
Equivalence Class Partitioning
Equivalence Class Testing
• Equivalence Classes form a partition of a set, where
partition refers to a collection of mutually disjoint
subsets, the union of which is the entire set.
• Disjointedness ensures redundancy
• Union provides completeness

• Equivalence Class testing


• Partition the input domain into EC
• Intervals might correspond to some “natural” distinctions in the input domain of
the problem being tested.

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Equivalence Class Testing
• Example:

XYZ College has developed a new system to


determine the grades earned by a student in a
subject, based on the cgpa:
Following are the rules:
– 0<= cgpa <= 4 : D
– 4< cgpa <= 6 : C
– 6< cgpa <= 8 : B
– 8< cgpa <= 10 : A

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Equivalence Class Testing
• Partitioning the input domain
• Example
• Program takes x1 and x2 as two inputs
• a<= x1 <= d, with intervals:
• [a, b), [b, c), [c, d]
• e<= x2 <= g, with intervals:
• [e, f), [f, g]

[ - closed interval
) – open interval

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Equivalence Class Testing
• Types of EC
• Weak Normal Equivalence Class (valid + single fault)
• Strong Normal Equivalence Class (valid + multiple fault assumption)
• Weak Robust Equivalence Class (valid + invalid + single fault assumption)
• Strong Robust Equivalence Class (valid + invalid + multiple fault assumption)

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Weak Normal EC

g
t2

x2
f
t1 t3

a b c d
x1

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Weak Normal EC
• Testing valid sub domains
• Based on single fault assumption
• Use one variable from each EC
• The number of weak EC test cases is same as classes in the
partition with the largest number of sets.
• t1
• x1 in the class [a, b)
• x2 in the class [e, f)
• t2
• x1 in the class [b, c)
• x2 in the class [f, g]
• Need another test case from EC : x1 in the class [c,d], with any
class of x2 : t3

• If a weak normal EC test case fails, there could be a problem with x1


or a problem with x2, or interaction between the two

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Strong Normal EC

g
t2
t4 t3

x2
f
t1 t5 t6

a b c d
x1

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Strong Normal EC
• Testing valid sub domains
• Based on multiple fault assumption
• Derive test cases based on the Cartesian product of
equivalence class
• Notion of completeness

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Weak Robust EC

t5

g
t2
t4
x2
f
t1 t3
t6

e
t7

a b c d
x1

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Weak Robust EC
• Based on single fault assumption
• Testing valid and invalid sub domains
• For invalid sub domain, select EC such that only at least
one variable in the valid domain

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Strong Robust EC

t7 t8 t9 t10 t11

g
t2 t12
t20 t4 t3

x2
f
t1 t5 t6 t13
t19

e t18 t17 t16 t15 t14

a b c d
x1

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Strong Robust EC
• Based on multiple fault assumption
• Testing valid and invalid sub domains

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Example- EC

A bank hosts a program on its website that determines the


maximum amount for which a credit card can be issued to a
user. The maximum limit is based on user annual income and
age. The following is the criteria applied:
Age Annual Income Credit Card Max Limit
31 <= Age <= 40 3 Lacs <= Income <= 5 Lacs Rs. 50,000
31 <= Age <= 40 5 Lacs < Income <= 10 Lacs Rs. 75,000
31 <= Age <= 40 10 Lacs < Income <= 15 Lacs Rs. 1 Lac
31 <= Age <= 40 Income > 15 Lacs Rs. 2 Lacs

40 < Age <= 50 3 Lacs <= Income <= 5 Lacs Rs. 75,000
40 < Age <= 50 5 Lacs < Income <= 10 Lacs Rs. 1 Lac
40 < Age <= 50 10 Lacs < Income <= 15 Lacs Rs. 2 Lac
40 < Age <= 50 Income > 15 Lacs Rs. 3 Lacs

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Example- EC
a) Derive the valid and invalid sub-domains for the input variables.
Justify any specific choice you make for the sub-domains.
Ans: Number of EC for age = 4 (2 valid and 2 invalid)
Number of EC for income = 5 (1 invalid + 4 valid) (only 1 invalid
case because upper limit is open)

b) Calculate the number of test cases for Strong Robust Equivalence


Class testing. State clearly the sub-domains chosen.
Ans:
Number of EC for age = 4 (2 valid and 2 invalid)
Number of EC for income = 5 (1 invalid + 4 valid) (only 1 invalid case
because upper limit is open)
Number of test cases for Strong Robust = 4 * 5 = 20

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Example- EC Test Case # Age Income Expected Output
1 35 1 Lac Invalid Income
2 35 4 Lac Rs. 50,000
c) Write down all the 3 35 7 Lac Rs. 75,000
test cases for Strong 4 35 12 Lac Rs. 1 Lac
5 35 17 Lac Rs. 2 Lacs
Robust Equivalence 6 45 1 Lac Invalid Income
Class testing. State 7 45 4 Lac Rs. 75,000
clearly the sub- 8 45 7 Lac Rs. 1 Lac
domains chosen. 9 45 12 Lac Rs. 2 Lac
10 45 17 Lac Rs. 3 Lacs
Invalid Age
11 60 1 Lac Invalid Income
12 60 4 Lac Invalid Age
13 60 7 Lac Invalid Age
14 60 12 Lac Invalid Age
15 60 17 Lac Invalid Age
Invalid Age
16 20 1 Lac Invalid Income
17 20 4 Lac Invalid Age
18 20 7 Lac Invalid Age
19 20 12 Lac Invalid Age
20 20 17 Lac Invalid Age

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Example- EC

d) Identify the equivalence classes for the valid output


domain. Write down sample test cases for the same.

Test Case # Age Income Expected Output


1 35 4 Lac Rs. 50,000
2 35 7 Lac Rs. 75,000
3 35 12 Lac Rs. 1 Lac
4 35 17 Lac Rs. 2 Lacs
5 45 4 Lac Rs. 75,000
6 45 7 Lac Rs. 1 Lac
7 45 12 Lac Rs. 2 Lac
8 45 17 Lac Rs. 3 Lacs

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Plan ahead…..

Go through Lecture Slides:


• Module 3: Specification Based Testing – Equivalence
Class Partitioning
• Module 4: Specification Based Testing – Decision Tables

Agenda: Lecture 4
• Module 5: Code Based Testing

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956

Вам также может понравиться