Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
9 views44 pages

07 EquivalenceClass

class

Uploaded by

kiranacchu1433
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views44 pages

07 EquivalenceClass

class

Uploaded by

kiranacchu1433
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 44

Equivalence Class Testing

Chapter 6
Boundary value problems

 What problems does boundary value testing have?

ECT–2
Boundary value problems – 2

 Generates test cases with


 Serious gaps
 Massive redundancy

ECT–3
Motivation for equivalence class testing

 What are the motivations for equivalence class testing?

ECT–4
Motivation for equivalence class testing – 2

 Avoid redundancy
 Have fewer test cases

 Complete testing
 Remove gaps

ECT–5
Addressing the motivation

 How do equivalence classes meet the motivations of


complete testing and avoiding redundancy?

ECT–6
Addressing the motivation– 2

 The variable domain is partitioned into disjoint sub-sets

ECT–7
Assumptions

 What assumptions are made?

ECT–8
Assumptions – 2

 Program is a function from input to output

 Input and/or output variables have well defined intervals

 For a two-variable function F(x1,x2)

a ≤ x1 ≤ d, with intervals [a,b), [b,c), [c,d]


e ≤ x2 ≤ g, with intervals [e,f), [f,g]

ECT–9
Assumptions – 3

 Completeness
 The entire set is represented by the union of the sub-sets

 Redundancy
 The disjointness of the sets assures a form of non-
redundancy

ECT–10
Selecting test values

 How are test values for a single variable selected?

ECT–11
Selecting test values – 2

 How are test values for a single variable selected?

 Choose one test value from each sub-set

ECT–12
Variations

 What variations are used for equivalence class testing?

ECT–13
Variations – 2

 Use the same two orthogonal dimensions as in boundary


value analysis
 Robustness
 Robust-normal

 Distinguishes valid data from invalid data

 Single/Multiple Fault Assumption


 Weak-strong

 Distinguishes single from multiple faults

 Combinations give four variations.

ECT–14
Weak-Normal ECT

 What is the number of test cases for weak-normal


testing?

ECT–15
Weak-Normal ECT – 2

Number of test cases =


max / [[ v : 1 .. #variables
• number_equivalence_classes (variable v) ]]

x2

e
x1
a b c d

ECT–16
Strong-Normal ECT

 What is the number of test cases for strong-normal


testing?

ECT–17
Strong-Normal ECT – 2

Number of test cases =


× / [[ v : 1 .. #variables
• number_equivalence_classes (variablev) ]]

x2

e
x1
a b c d

ECT–18
Weak-Robust ECT

 What is the number of test cases for weak-robust


testing?

ECT–19
Weak-Robust ECT – 2

Number of test cases =


max / [[ v : 1 .. #variables
• number_equivalence_classes (variablev) ]]
+
+/ [[ v : 1 .. #variables
• number_invalid_bounds (variablev) ]]
x2

f
Figure 6.3 in
e the textbook
is incorrect
x1
a b c d
ECT–20
Strong-Robust ECT

 What is the number of test cases for strong-robust


testing?

ECT–21
Strong-Robust ECT – 2

Number of test cases =


× / [[ v : 1 .. #variables
• number_equivalence_classes (variablev)
+ number_invalid_bounds (variablev) ]]

x2

e
x1
a b c d

ECT–22
Limitations of ECT

 What are the limitations of equivalence class testing?

ECT–23
Limitations of ECT – 2

 The same as those for boundary value testing

 Does not work well for Boolean variables

 Does not work well for logical variables

 When variables are not independent – i.e. are dependent

ECT–24
Limitations of ECT – 3

 For robust variations same as for boundary value testing


 Difficult or impossible to determine expected values for
invalid variable values
 Not useful for strongly-typed languages

ECT–25
Triangle Output Equivalence Classes

 Four possible outputs


 Not a Triangle
 Isosceles
 Equilateral
 Scalene

ECT–26
Triangle Output Equivalence Classes – 2

 Output (range) equivalence classes

O1 = {a, b, c : 0 .. 200 | equilateral_triangle ( <a,b,c> ) }

O2 = {a, b, c : 0 .. 200 | isoceles_triangle ( <a,b,c> ) }

O3 = {a, b, c : 0 .. 200 | scalene_triangle ( <a,b,c> ) }

O4 = {a, b, c : 0 .. 200 | not_a_triangle ( <a,b,c> ) }

What is the number of test cases for weak-normal?

ECT–27
Triangle – Weak-Normal

Does the number of cases follow the formula in slide 16?

Expected
Test Case a b c
Output

WN1 5 5 5 Equilateral

WN2 2 2 3 Isosceles

WN3 3 4 5 Scalene

Not a
WN4 4 1 2
Triangle

ECT–28
Triangle Strong-Normal

 Output (range) equivalence classes

O1 = {a, b, c : 0 .. 200 | equilateral_triangle ( <a,b,c> ) }

O2 = {a, b, c : 0 .. 200 | isoceles_triangle ( <a,b,c> ) }

O3 = {a, b, c : 0 .. 200 | scalene_triangle ( <a,b,c> ) }

O4 = {a, b, c : 0 .. 200 | not_a_triangle ( <a,b,c> ) }

What is the number of test cases for strong-normal?

ECT–29
Triangle – Strong-Normal = Weak-Normal

Does the number of cases follow the formula in slide 18?

Expected
Test Case a b c
Output

WN1 5 5 5 Equilateral

WN2 2 2 3 Isosceles

WN3 3 4 5 Scalene

Not a
WN4 4 1 2
Triangle

ECT–30
Triangle Weak-Robust

 Output (range) equivalence classes

O1 = {a, b, c : 0 .. 200 | equilateral_triangle ( <a,b,c> ) }

O2 = {a, b, c : 0 .. 200 | isoceles_triangle ( <a,b,c> ) }

O3 = {a, b, c : 0 .. 200 | scalene_triangle ( <a,b,c> ) }

O4 = {a, b, c : 0 .. 200 | not_a_triangle ( <a,b,c> ) }

What are the number of test cases for weak-robust?

ECT–31
Triangle – Weak Robust Test Cases

Weak-normal cases + following error cases


Does the count follow the formula in slide 20?

Expected
Test Case a b c
Output
WR1 -1 5 5 a not in range

WR2 5 -1 5 b not in range

WR3 5 5 -1 c not in range

WR4 201 5 5 a not in range

WR5 5 201 5 b not in range

WR6 5 5 201 c not in range

ECT–32
Triangle Strong-Robust

 Output (range) equivalence classes

O1 = {a, b, c : 0 .. 200 | equilateral_triangle ( <a,b,c> ) }

O2 = {a, b, c : 0 .. 200 | isoceles_triangle ( <a,b,c> ) }

O3 = {a, b, c : 0 .. 200 | scalene_triangle ( <a,b,c> ) }

O4 = {a, b, c : 0 .. 200 | not_a_triangle ( <a,b,c> ) }

What are the number of test cases for strong-robust?

ECT–33
Triangle – Strong-Robust Test Cases

 #strong-normal = #weak-normal = 4

 #Error cases = all combinations of errors in one or more of


a, b and c.
 Each of a, b c have 3 values
 too low • normal • too high
 All combinations with at least one error
 3^3 – 1 = 26 Remove normal-normal-normal

 Total = 30
Triangle – input equivalence classes

What are the number


of test cases for
D1 = { a,b,c : 1..200 | a = b = c • <a,b,c> }
• weak-normal?
D2 = { a,b,c : 1..200 | a = b, a ≠ c • <a,b,c> } • strong-normal?
• weak-robust?
D3 = { a,b,c : 1..200 | a = c, a ≠ b • <a,b,c> }
• strong-robust?
D4 = { a,b,c : 1..200 | b = c, a ≠ b • <a,b,c> }
D5 = { a,b,c : 1..200 | a ≠ b, a ≠ c, b ≠ c • <a,b,c> }
D6 = { a,b,c : 1..200 | a ≥ b+c • <a,b,c> }
D7 = { a,b,c : 1..200 | b ≥ a+c • <a,b,c> } Is this a good set of
D8 = { a,b,c : 1..200 | c ≥ a+b • <a,b,c> } equivalence classes
to use or is there a
problem?

ECT–35
NextDate – naive equivalence classes

M1 = { month : 1 .. 12 } What are the number


D1 = { day : 1 .. 31 } of test cases for
• weak-normal?
Y1 = { year : 1812 .. 2012 } • strong-normal?
• weak-robust?
Invalid data
• strong-robust?
M2 = { month : Integer | month < 1 }
M3 = { month : Integer | month > 12 }
D2 = { day : Integer | day < 1 }
D3 = { day : Integer | day > 31 } What is the problem
Y2 = { year : Integer | year < 1812 } with using these
equivalence classes?
Y3 = { year : Integer | year > 2012 }

ECT–36
NextDate – improved equivalence classes

M1 = {month : 1 .. 12 | days(month) = 30 }
M2 = {month : 1 .. 12 | days(month) = 31 }
M3 = {month : {2} }
D1 = {day : 1 .. 28}
What is good and bad
D2 = {day : {29} } with using these
equivalence classes?
D3 = {day : {30} }
D4 = {day : {31} }
Y1 = {year : {2000} }
Y2 = {year : 1812 .. 2012 | leap_year (year) ∧ year ≠ 2000 }
Y3 = {year : 1812 .. 2012 | common_year (year) }

ECT–37
Weak Normal Test Cases

Expected
Test Case Month Day Year
Output

WN1 6 14 1900 6/15/1900

WN2 7 29 1996 7/30/1996

Invalid input
WN3 2 30 2002
date

Invalid input
WN4 6 31 1900
date

ECT–38
NextDate strong test cases

 What are the number of test cases for


strong-normal testing?

 What are the number of test cases for


strong-robust testing?

ECT–39
NextDate strong test cases – 2

 There are 36 strong-normal test cases (3 x 4 x 3)


 Some redundancy creeps in
 Testing February 30 and 31 for three different types of
years seems unlikely to reveal errors

 There are 150 strong-robust test cases (5 x 6 x 5)

ECT–40
Commission problem – input classes

L1 = {locks : 1 .. 70 } What are the number


of test cases for
L2 = {locks : { -1 } }
• weak-normal?
S1 = {stocks : 1 .. 80 }
• strong-normal?
B1 = {barrels : 1 .. 90} • weak-robust?
Invalid data • strong-robust?
L3 = {locks : Integer | locks ≤ 0 ∧ locks ≠ -1}
L4 = {locks : Integer | locks > 70 }
S2 = {stocks : Integer | stocks < 1 }
What is good and
S3 = {stocks : Integer | stocks > 80 } not good about
using these classes?
B2 = {barrels : Integer | barrels < 1 }
B3 = {barrels : Integer | barrels > 90 }

ECT–41
Commission problem – output classes

What are the number


Sales = 45 × locks + 30 × stocks + 25 × barrels of test cases for
• weak-normal?
• strong-normal?
S1 = {sales : 0 .. 1000 } • weak-robust?
S2 = {sales : 1001 .. 1800 } • strong-robust?

S3 = {sales : Integer | sales > 1800 }


Invalid data
What is good and
S4 = {sales : Integer | sales < 0} not good about
using these classes?

Figure 5.6, page 84 shows the


classes pictorially

ECT–42
Guidelines and observations

 Equivalence Class Testing is appropriate when input data is


defined in terms of intervals and sets of discrete values.

 Equivalence Class Testing is strengthened when combined


with Boundary Value Testing

 Strong equivalence makes the presumption that variables


are independent.
 If that is not the case, redundant test cases may be
generated

ECT–43
Guidelines and observations – 2

 Complex functions, such as the NextDate program, are well-


suited for Equivalence Class Testing

 Several tries may be required before the “right” equivalence


relation is discovered
 If the equivalence classes are chosen wisely, the potential
redundancy among test cases is greatly reduced.

 The key point in equivalence class testing is the choice of


the equivalence relation that determines the classes.

ECT–44

You might also like