Você está na página 1de 56

Functional Testing Part 1

Boundary Value Testing – Equivalence Class Testing


Agenda
 Boundary Value Testing
 Boundary Value Analysis
 Generalizing Boundary Value Analysis
 Limitations of Boundary Value Analysis
 Robustness Testing
 Worst Case Testing
 Special Value Testing
 Examples
 Test Cases for the Triangle Problem
 Test Cases for the NextDate Problem
 Test Cases for the Commission Problem
 Guidelines for Boundary value Testing
 Equivalence Class Testing
 Equivalence Classes
 Weak Equivalence Class Testing
 Strong Equivalence Class Testing
 Traditional Equivalence Class Testing
 Equivalence Class Test Cases for the Triangle Problem
 Equivalence Class Test Cases for the NextDate Function
 Equivalence Class Test Cases for the Commission Problem
 Guidelines and Observations

2
Agenda
 Boundary Value Testing
 Boundary Value Analysis
 Generalizing Boundary Value Analysis
 Limitations of Boundary Value Analysis
 Robustness Testing
 Worst Case Testing
 Special Value Testing
 Examples
 Test Cases for the Triangle Problem
 Test Cases for the NextDate Problem
 Test Cases for the Commission Problem
 Guidelines for Boundary value Testing
 Equivalence Class Testing
 Equivalence Classes
 Weak Equivalence Class Testing
 Strong Equivalence Class Testing
 Traditional Equivalence Class Testing
 Equivalence Class Test Cases for the Triangle Problem
 Equivalence Class Test Cases for the NextDate Function
 Equivalence Class Test Cases for the Commission Problem
 Guidelines and Observations

3
Boundary Value Analysis

 F(x1, x2), a ≤ x1 ≤ b, c ≤ x2 ≤ d
 Boundary value analysis focuses on the
boundary of the input space to identify test
cases
 The rationale behind boundary value
testing is that errors tend to occur near the
extreme values of an input variable
 e.g. loop conditions (< instead of ≤), counters

4
Boundary Value Analysis
 Basic idea: use input variable values at their
minimum (min), just above the minimum (min+),
a nominal value (nom), just below their
maximum (max-), and at their maximum (max)
 “Single fault” assumption in reliability theory:
failures are only rarely the result of the
simultaneous occurrence of two (or more) faults.
 The boundary value analysis test cases are
obtained by holding the values of all but one
variable at their nominal values, and letting that
variable assume its extreme values
5
Boundary Value Analysis

F(x1, x2)
x2 Input Space (domain) x2 Test Cases (function
of two variables)
<x1nom , x2min>
<x1nom , x2min+>
d d <x 1nom, x2nom >
<x1nom , x2max->
<x1nom, x2max>
<x1min, x2nom >
<x1min+, x2nom >
<x 1nom, x2nom >
<x1max-, x2nom >
c c <x1max, x2nom>

x1 x1
a b a b

6
Agenda
 Boundary Value Testing
 Boundary Value Analysis
 Generalizing Boundary Value Analysis
 Limitations of Boundary Value Analysis
 Robustness Testing
 Worst Case Testing
 Special Value Testing
 Examples
 Test Cases for the Triangle Problem
 Test Cases for the NextDate Problem
 Test Cases for the Commission Problem
 Guidelines for Boundary value Testing
 Equivalence Class Testing
 Equivalence Classes
 Weak Equivalence Class Testing
 Strong Equivalence Class Testing
 Traditional Equivalence Class Testing
 Equivalence Class Test Cases for the Triangle Problem
 Equivalence Class Test Cases for the NextDate Function
 Equivalence Class Test Cases for the Commission Problem
 Guidelines and Observations

7
Generalizing Boundary Value Analysis

 By the number of variables


 For n variables → 4n + 1 test cases
 By the kinds of ranges, depends on the type (nature) of
the variables
 Variables have discrete, bounded values
 e.g. NextDate function, commission problem
 Variables have no explicit bounds
 Create “artificial” bounds
 e.g. triangle problem
 Boolean variables
 Decision table-based testing
 Logical variables (bound to a value or another logic variable)
 e.g. PIN and transaction type in SATM System

8
Agenda
 Boundary Value Testing
 Boundary Value Analysis
 Generalizing Boundary Value Analysis
 Limitations of Boundary Value Analysis
 Robustness Testing
 Worst Case Testing
 Special Value Testing
 Examples
 Test Cases for the Triangle Problem
 Test Cases for the NextDate Problem
 Test Cases for the Commission Problem
 Guidelines for Boundary value Testing
 Equivalence Class Testing
 Equivalence Classes
 Weak Equivalence Class Testing
 Strong Equivalence Class Testing
 Traditional Equivalence Class Testing
 Equivalence Class Test Cases for the Triangle Problem
 Equivalence Class Test Cases for the NextDate Function
 Equivalence Class Test Cases for the Commission Problem
 Guidelines and Observations

9
Limitations of Boundary Value Analysis

 Boundary value analysis works well when


the program to be tested is a function of
several independent variables that
represent bounded physical quantities
 e.g. NextDate test cases are inadequate (little
stress on February, dependencies among
month, day, and year)
 e.g. variables refer to physical quantities,
such as temperature, air speed, load etc.

10
Agenda
 Boundary Value Testing
 Boundary Value Analysis
 Generalizing Boundary Value Analysis
 Limitations of Boundary Value Analysis
 Robustness Testing
 Worst Case Testing
 Special Value Testing
 Examples
 Test Cases for the Triangle Problem
 Test Cases for the NextDate Problem
 Test Cases for the Commission Problem
 Guidelines for Boundary value Testing
 Equivalence Class Testing
 Equivalence Classes
 Weak Equivalence Class Testing
 Strong Equivalence Class Testing
 Traditional Equivalence Class Testing
 Equivalence Class Test Cases for the Triangle Problem
 Equivalence Class Test Cases for the NextDate Function
 Equivalence Class Test Cases for the Commission Problem
 Guidelines and Observations

11
Robustness Testing
 Simple extension of boundary value analysis
 In addition to the five boundary value analysis
values of a variable, see what happens when the
extrema are exceeded with a value slightly
greater than the maximum (max+) and a value
slightly less than the minimum (min-)
 Focuses on the expected outputs
 e.g. exceeding load capacity of a public elevator
 Forces attention on exception handling

12
Robustness Testing

x2 Robustness Test Cases


<x1nom , x2min>
(function of two variables) <x1nom , x2min+>
<x 1nom, x2nom >
<x1nom , x2max->
d <x1nom, x2max>
<x1min, x2nom >
<x1min+, x2nom >
<x 1nom, x2nom >
<x1max-, x2nom >
<x1max, x2nom>
<x 1min-, x2nom >
<x1nom , x2max+>
c <x1max+, x2nom>
<x 1nom, x2min- >

x1
a b

13
Agenda
 Boundary Value Testing
 Boundary Value Analysis
 Generalizing Boundary Value Analysis
 Limitations of Boundary Value Analysis
 Robustness Testing
 Worst Case Testing
 Special Value Testing
 Examples
 Test Cases for the Triangle Problem
 Test Cases for the NextDate Problem
 Test Cases for the Commission Problem
 Guidelines for Boundary value Testing
 Equivalence Class Testing
 Equivalence Classes
 Weak Equivalence Class Testing
 Strong Equivalence Class Testing
 Traditional Equivalence Class Testing
 Equivalence Class Test Cases for the Triangle Problem
 Equivalence Class Test Cases for the NextDate Function
 Equivalence Class Test Cases for the Commission Problem
 Guidelines and Observations

14
Worst Case Testing
 Worst case analysis: more than one variable has an
extreme value
 Procedure:
 For each variable create the set <min, min+, nom, max-, max>
 Take the Cartesian product of these sets to generate test cases
 More thorough than boundary value analysis
 Represents more effort
 For n variables → 5n test cases (as opposed to 4n+1 test cases
for boundary value analysis)
 Follows the generalization pattern
 Same limitations
 Robust worst case testing can be applied

15
Worst Case Testing

Worst Case Test <x 1min, x2min> <x1max-, x2min>


x2
Cases (function of two <x1min, x2min+> <x1max-, x2min+>
variables) <x1min, x2nom > <x1max-, x2nom >
<x1min, x2max-> <x1max-, x2max->
d <x1min, x2max> <x 1max-, x2max>
<x1min+, x2min> <x1max, x2min>
<x1min+, x2min+> <x 1max, x2min+>
<x1min+, x2nom > <x1max, x2nom>
<x1min+, x2max-> <x 1max, x2max->
<x 1min+, x2max> <x1max, x2max>
<x1nom , x2min>
c <x1nom , x2min+>
<x 1nom, x2nom >
x1 <x1nom , x2max->
a b
<x1nom, x2max>

16
Worst Case Testing

x2 Robust Worst Case Test <x 1min-, x2min- > <x1min+, x2min- > <x1max-, x2min- > <x1max+, x2min->
Cases (function of two
<x1min- , x2min> <x1min+, x2min> <x1max-, x2min> <x 1max+, x2min >
variables) <x1min- , x2min+> <x1min+, x2min+> <x1max-, x2min+> <x1max+, x2min+>
<x 1min-, x2nom > <x1min+, x2nom > <x1max-, x2nom > <x1max+, x2nom>
d
<x1min- , x2max-> <x1min+, x2max-> <x1max-, x2max-> <x1max+, x2max->
<x1min-, x2max> <x 1min+, x2max> <x 1max-, x2max> <x1max+, x2max>
<x1min- , x2max+> <x1min+, x2max+> <x1max-, x2max+> <x 1max+, x2max+>
<x1min, x2min-> <x 1nom, x2min- > <x1max, x2min->
<x 1min, x2min> <x1nom , x2min> <x1max, x2min>
<x1min, x2min+> <x1nom , x2min+> <x 1max, x2min+>
<x1min, x2nom > <x 1nom, x2nom > <x1max, x2nom>
c
<x1min, x2max-> <x1nom , x2max-> <x 1max, x2max->
<x1min, x2max> <x1nom, x2max> <x1max, x2max>
x1
a b <x 1min, x2max+> <x1nom , x2max+> <x1max, x2max+>

17
Agenda
 Boundary Value Testing
 Boundary Value Analysis
 Generalizing Boundary Value Analysis
 Limitations of Boundary Value Analysis
 Robustness Testing
 Worst Case Testing
 Special Value Testing
 Examples
 Test Cases for the Triangle Problem
 Test Cases for the NextDate Problem
 Test Cases for the Commission Problem
 Guidelines for Boundary value Testing
 Equivalence Class Testing
 Equivalence Classes
 Weak Equivalence Class Testing
 Strong Equivalence Class Testing
 Traditional Equivalence Class Testing
 Equivalence Class Test Cases for the Triangle Problem
 Equivalence Class Test Cases for the NextDate Function
 Equivalence Class Test Cases for the Commission Problem
 Guidelines and Observations

18
Special Value Testing
 The most widely practiced form of functional
testing
 Most intuitive, least uniform, no guidelines
 The tester uses his/her domain knowledge,
experience with similar programs, “ad hoc
testing”
 It is dependent on the abilities of the tester
 Even though it is highly subjective, it often
results in a set of test cases which is more
effective in revealing faults than the test sets
generated by the other methods

19
Agenda
 Boundary Value Testing
 Boundary Value Analysis
 Generalizing Boundary Value Analysis
 Limitations of Boundary Value Analysis
 Robustness Testing
 Worst Case Testing
 Special Value Testing
 Examples
 Test Cases for the Triangle Problem
 Test Cases for the NextDate Problem
 Test Cases for the Commission Problem
 Guidelines for Boundary value Testing
 Equivalence Class Testing
 Equivalence Classes
 Weak Equivalence Class Testing
 Strong Equivalence Class Testing
 Traditional Equivalence Class Testing
 Equivalence Class Test Cases for the Triangle Problem
 Equivalence Class Test Cases for the NextDate Function
 Equivalence Class Test Cases for the Commission Problem
 Guidelines and Observations

20
Test Cases for the Triangle Problem

Boundary Value Analysis Test Cases


Case a b c Expected Output
1 100 100 1 Isosceles
2 100 100 2 Isosceles
min = 1
3 100 100 100 Equilateral
min+ = 2 4 100 100 199 Isosceles
nom = 100 5 100 100 200 Not a Triangle
max- = 199
6 100 1 100 Isosceles
max = 200
7 100 2 100 Isosceles
8 100 199 100 Isosceles
9 100 200 100 Not a Triangle
10 1 100 100 Isosceles
11 2 100 100 Isosceles
12 199 100 100 Isosceles
13 200 100 100 Not a Triangle

21
Test Cases for the Triangle Problem
Worst Case Test Cases (60 of 125)
Case a b c Expected Output Case a b c Expected Output
1 1 1 1 Equilateral 31 2 2 1 Isosceles
2 1 1 2 Not a Triangle 32 2 2 2 Equilateral
3 1 1 100 Not a Triangle 33 2 2 100 Not a Triangle
4 1 1 199 Not a Triangle 34 2 2 199 Not a Triangle
5 1 1 200 Not a Triangle 35 2 2 200 Not a Triangle
6 1 2 1 Not a Triangle 36 2 100 1 Not a Triangle
7 1 2 2 Isosceles 37 2 100 2 Not a Triangle
8 1 2 100 Not a Triangle 38 2 100 100 Isosceles
9 1 2 199 Not a Triangle 39 2 100 199 Not a Triangle
10 1 2 200 Not a Triangle 40 2 100 200 Not a Triangle
11 1 100 1 Not a Triangle 41 2 199 1 Not a Triangle
12 1 100 2 Not a Triangle 42 2 199 2 Not a Triangle
13 1 100 100 Isosceles 43 2 199 100 Not a Triangle
14 1 100 199 Not a Triangle 44 2 199 199 Isosceles
15 1 100 200 Not a Triangle 45 2 199 200 Scalene
16 1 199 1 Not a Triangle 46 2 200 1 Not a Triangle
17 1 199 2 Not a Triangle 47 2 200 2 Not a Triangle
18 1 199 100 Not a Triangle 48 2 200 100 Not a Triangle
19 1 199 199 Isosceles 49 2 200 199 Scalene
20 1 199 200 Not a Triangle 50 2 200 200 Isosceles
21 1 200 1 Not a Triangle 51 100 1 1 Not a Triangle
22 1 200 2 Not a Triangle 52 100 1 2 Not a Triangle
23 1 200 100 Not a Triangle 53 100 1 100 Isosceles
24 1 200 199 Not a Triangle 54 100 1 199 Not a Triangle
25 1 200 200 Isosceles 55 100 1 200 Not a Triangle
26 2 1 1 Not a Triangle 56 100 2 1 Not a Triangle
27 2 1 2 Isosceles 57 100 2 2 Not a Triangle
28 2 1 100 Not a Triangle 58 100 2 100 Isosceles
29 2 1 199 Not a Triangle 59 100 2 199 Not a Triangle
30 2 1 200 Not a Triangle 60 100 2 200 Not a Triangle

22
Agenda
 Boundary Value Testing
 Boundary Value Analysis
 Generalizing Boundary Value Analysis
 Limitations of Boundary Value Analysis
 Robustness Testing
 Worst Case Testing
 Special Value Testing
 Examples
 Test Cases for the Triangle Problem
 Test Cases for the NextDate Problem
 Test Cases for the Commission Problem
 Guidelines for Boundary value Testing
 Equivalence Class Testing
 Equivalence Classes
 Weak Equivalence Class Testing
 Strong Equivalence Class Testing
 Traditional Equivalence Class Testing
 Equivalence Class Test Cases for the Triangle Problem
 Equivalence Class Test Cases for the NextDate Function
 Equivalence Class Test Cases for the Commission Problem
 Guidelines and Observations

23
Test Cases for the NextDate Problem

Boundary Value Analysis Test Cases


Case month day year Expected Output
1 6 15 1812 June 16, 1812
2 6 15 1813 June 16, 1813
3 6 15 1912 June 16, 1912
month day year
min = 1 min = 1 min = 1812 4 6 15 2011 June 16, 2011
min+ = 2 min+ = 2 min+ = 1813 5 6 15 2012 June 16, 2012
nom = 6 nom = 15 nom = 1912 6 6 1 1912 June 2, 1912
max- = 11 max- = 30 max- = 2011 7 6 2 1912 June 3, 1912
max = 12 max = 31 max = 2012
8 6 30 1912 July 1, 1912
9 6 31 1912 error
10 1 15 1912 January 16, 1912
11 2 15 1912 February 16, 1912
12 11 15 1912 November 16, 1912
13 12 15 1912 December 16, 1912

24
Test Cases for the NextDate Problem
Worst Case Test Cases (60 of 125)
Case month day year Expected Output Case month day year Expected Output
1 1 1 1812 January 2, 1812 31 2 2 1812 February 3, 1812
2 1 1 1813 January 2, 1813 32 2 2 1813 February 3, 1813
3 1 1 1912 January 2, 1912 33 2 2 1912 February 3, 1912
4 1 1 2011 January 2, 2011 34 2 2 2011 February 3, 2011
5 1 1 2012 January 2, 2012 35 2 2 2012 February 3, 2012
6 1 2 1812 January 3, 1812 36 2 15 1812 February 16, 1812
7 1 2 1813 January 3, 1813 37 2 15 1813 February 16, 1813
8 1 2 1912 January 3, 1912 38 2 15 1912 February 16, 1912
9 1 2 2011 January 3, 2011 39 2 15 2011 February 16, 2011
10 1 2 2012 January 3, 2012 40 2 15 2012 February 16, 2012
11 1 15 1812 January 16, 1812 41 2 30 1812 error
12 1 15 1813 January 16, 1813 42 2 30 1813 error
13 1 15 1912 January 16, 1912 43 2 30 1912 error
14 1 15 2011 January 16, 2011 44 2 30 2011 error
15 1 15 2012 January 16, 2012 45 2 30 2012 error
16 1 30 1812 January 31, 1812 46 2 31 1812 error
17 1 30 1813 January 31, 1813 47 2 31 1813 error
18 1 30 1912 January 31, 1912 48 2 31 1912 error
19 1 30 2011 January 31, 2011 49 2 31 2011 error
20 1 30 2012 January 31, 2012 50 2 31 2012 error
21 1 31 1812 February 1, 1812 51 6 1 1812 June 2, 1812
22 1 31 1813 February 1, 1813 52 6 1 1813 June 2, 1813
23 1 31 1912 February 1, 1912 53 6 1 1912 June 2, 1912
24 1 31 2011 February 1, 2011 54 6 1 2011 June 2, 2011
25 1 31 2012 February 1, 2012 55 6 1 2012 June 2, 2012
26 2 1 1812 February 2, 1812 56 6 2 1812 June 3, 1812
27 2 1 1813 February 2, 1813 57 6 2 1813 June 3, 1813
28 2 1 1912 February 2, 1912 58 6 2 1912 June 3, 1912
29 2 1 2011 February 2, 2011 59 6 2 2011 June 3, 2011
30 2 1 2012 February 2, 2012 60 6 2 2012 June 3, 2012

25
Agenda
 Boundary Value Testing
 Boundary Value Analysis
 Generalizing Boundary Value Analysis
 Limitations of Boundary Value Analysis
 Robustness Testing
 Worst Case Testing
 Special Value Testing
 Examples
 Test Cases for the Triangle Problem
 Test Cases for the NextDate Problem
 Test Cases for the Commission Problem
 Guidelines for Boundary value Testing
 Equivalence Class Testing
 Equivalence Classes
 Weak Equivalence Class Testing
 Strong Equivalence Class Testing
 Traditional Equivalence Class Testing
 Equivalence Class Test Cases for the Triangle Problem
 Equivalence Class Test Cases for the NextDate Function
 Equivalence Class Test Cases for the Commission Problem
 Guidelines and Observations

26
Test Cases for the Commission Problem

 13 Boundary Value Analysis Test Cases


 125 Worst Case Test Cases
 Boundary values for the output range, especially
near the threshold points of $1000 and $1800
 Part of the reason for using the output range to
determine test cases is that test cases from the
input range are almost all in the 20% zone
 We want to find input variable combinations that
stress the boundary values: $100, $1000,
$1800, and $7800

27
Test Cases for the Commission Problem
Output Boundary Value Analysis Test Cases
Case locks stocks barrels sales commission comment
1 1 1 1 100 10 output minimum
2 1 1 2 125 12.5 output minimum +
3 1 2 1 130 13 output minimum +
4 2 1 1 145 14.5 output minimum +
5 5 5 5 500 50 midpoint
6 10 10 9 975 97.5 border point -
7 10 9 10 970 97 border point -
8 9 10 10 955 95.5 border point -
9 10 10 10 1000 100 border point
10 10 10 11 1025 103.75 border point +
11 10 11 10 1030 104.5 border point +
12 11 10 10 1045 106.75 border point +
13 14 14 14 1400 160 midpoint
14 18 18 17 1775 216.25 border point -
15 18 17 18 1770 215.5 border point -
16 17 18 18 1755 213.25 border point -
17 18 18 18 1800 220 border point
18 18 18 19 1825 225 border point +
19 18 19 18 1830 226 border point +
20 19 18 18 1845 229 border point +
21 48 48 48 4800 820 midpoint
22 70 80 89 7775 1415 output maximum -
23 70 79 90 7770 1414 output maximum -
24 69 80 90 7755 1411 output maximum -
25 70 80 90 7800 1420 output maximum

28
Test Cases for the Commission Problem

 Test case 9 is the $1000 border point


 If we tweak the input variables we get
values just below and just above the
border
 Form of special value testing based on
mathematical insight
Output Special Value Test Cases
Case locks stocks barrels sales commission comment
1 10 11 9 1005 100.75 border point +
2 18 17 19 1795 219.25 border point -
3 18 19 17 1805 221 border point +

29
Agenda
 Boundary Value Testing
 Boundary Value Analysis
 Generalizing Boundary Value Analysis
 Limitations of Boundary Value Analysis
 Robustness Testing
 Worst Case Testing
 Special Value Testing
 Examples
 Test Cases for the Triangle Problem
 Test Cases for the NextDate Problem
 Test Cases for the Commission Problem
 Guidelines for Boundary value Testing
 Equivalence Class Testing
 Equivalence Classes
 Weak Equivalence Class Testing
 Strong Equivalence Class Testing
 Traditional Equivalence Class Testing
 Equivalence Class Test Cases for the Triangle Problem
 Equivalence Class Test Cases for the NextDate Function
 Equivalence Class Test Cases for the Commission Problem
 Guidelines and Observations

30
Equivalence Classes
 Motivations
 Have a sense of complete testing
 Avoid redundancy
 Equivalence classes form a partition of a set, where partition refers
to a collection of mutually disjoint subsets whose union is the entire
set (completeness, non-redundancy)
 The idea is to identify test cases by using one element from each
equivalence class
 “treated the same” → “traversing the same execution path”
 The key is the choice of the equivalence relation that determines the
classes
 “second guess” the likely implementation , and think about the functional
manipulations that must somehow be present in the implementation

31
Equivalence Classes

 Program under consideration:


 Function of variables a, b, c
 Input domain consists of sets A, B, and C

 A = A1 A2 A3
 B = B1 B2 B3 B4
 C = C1 C2
 a1 ∈ A1, b3 ∈ B3, c2 ∈ C2

32
Agenda
 Boundary Value Testing
 Boundary Value Analysis
 Generalizing Boundary Value Analysis
 Limitations of Boundary Value Analysis
 Robustness Testing
 Worst Case Testing
 Special Value Testing
 Examples
 Test Cases for the Triangle Problem
 Test Cases for the NextDate Problem
 Test Cases for the Commission Problem
 Guidelines for Boundary value Testing
 Equivalence Class Testing
 Equivalence Classes
 Weak Equivalence Class Testing
 Strong Equivalence Class Testing
 Traditional Equivalence Class Testing
 Equivalence Class Test Cases for the Triangle Problem
 Equivalence Class Test Cases for the NextDate Function
 Equivalence Class Test Cases for the Commission Problem
 Guidelines and Observations

33
Weak Equivalence Class Testing

 Accomplished by using one variable from


each equivalence class in a test case
Test Case a b c
A = A1 A2 A3 WE1 a1 b1 c1
B = B1 B2 B3 B4
C = C1 C2 WE2 a2 b2 c2
a1 ∈ A1, b3 ∈ B3, c2 ∈ C2 WE3 a3 b3 c1
WE4 a1 b4 c2

 Number of weak equivalence class test


cases = number of classes in the partition
with the largest number of subsets
34
Agenda
 Boundary Value Testing
 Boundary Value Analysis
 Generalizing Boundary Value Analysis
 Limitations of Boundary Value Analysis
 Robustness Testing
 Worst Case Testing
 Special Value Testing
 Examples
 Test Cases for the Triangle Problem
 Test Cases for the NextDate Problem
 Test Cases for the Commission Problem
 Guidelines for Boundary value Testing
 Equivalence Class Testing
 Equivalence Classes
 Weak Equivalence Class Testing
 Strong Equivalence Class Testing
 Traditional Equivalence Class Testing
 Equivalence Class Test Cases for the Triangle Problem
 Equivalence Class Test Cases for the NextDate Function
 Equivalence Class Test Cases for the Commission Problem
 Guidelines and Observations

35
Strong Equivalence Class Testing
Test Case a b c
 Based on the Cartesian SE1
SE2
a1
a1
b1
b1
c1
c2

Product of the partition SE3


SE4
a1
a1
b2
b2
c1
c2

subsets
SE5 a1 b3 c1
SE6 a1 b3 c2
SE7 a1 b4 c1
 A x B x C = 3 x 4 x 2 = 24 SE8
SE9
SE10
a1
a2
a2
b4
b1
b1
c2
c1
c2
elements SE11
SE12
a2
a2
b2
b2
c1
c2

Equivalence relations can


SE13 a2 b3 c1
 SE14 a2 b3 c2
SE15 a2 b4 c1
be defined on the output SE16
SE17
a2
a3
b4
b1
c2
c1

range of the program SE18


SE19
a3
a3
b1
b2
c2
c1

function being tested


SE20 a3 b2 c2
SE21 a3 b3 c1
SE22 a3 b3 c2
SE23 a3 b4 c1
SE24 a3 b4 c2

36
Agenda
 Boundary Value Testing
 Boundary Value Analysis
 Generalizing Boundary Value Analysis
 Limitations of Boundary Value Analysis
 Robustness Testing
 Worst Case Testing
 Special Value Testing
 Examples
 Test Cases for the Triangle Problem
 Test Cases for the NextDate Problem
 Test Cases for the Commission Problem
 Guidelines for Boundary value Testing
 Equivalence Class Testing
 Equivalence Classes
 Weak Equivalence Class Testing
 Strong Equivalence Class Testing
 Traditional Equivalence Class Testing
 Equivalence Class Test Cases for the Triangle Problem
 Equivalence Class Test Cases for the NextDate Function
 Equivalence Class Test Cases for the Commission Problem
 Guidelines and Observations

37
Traditional Equivalence Class Testing

 Defines equivalence classes in terms of validity


 Commission problem
 Valid inputs: 1 ≤ lock ≤ 70, 1 ≤ stock ≤ 80,
1 ≤ barrel ≤ 90
 Invalid inputs: lock < 1, lock > 70, stock < 1,
stock > 80, barrel < 1, barrel > 90
 For valid inputs, use one value from each valid
class (like weak equivalence testing)
 For invalid inputs, a test case will have one
invalid value and the remaining values will all be
valid (single failure)
38
Traditional Equivalence Class Testing

 Problems:
 Very often, the specification does not define
what the expected output for an invalid test
case should be → a lot of time spent in
defining expected outputs
 Strongly typed languages eliminate the need
for the consideration of invalid inputs

39
Agenda
 Boundary Value Testing
 Boundary Value Analysis
 Generalizing Boundary Value Analysis
 Limitations of Boundary Value Analysis
 Robustness Testing
 Worst Case Testing
 Special Value Testing
 Examples
 Test Cases for the Triangle Problem
 Test Cases for the NextDate Problem
 Test Cases for the Commission Problem
 Guidelines for Boundary value Testing
 Equivalence Class Testing
 Equivalence Classes
 Weak Equivalence Class Testing
 Strong Equivalence Class Testing
 Traditional Equivalence Class Testing
 Equivalence Class Test Cases for the Triangle Problem
 Equivalence Class Test Cases for the NextDate Function
 Equivalence Class Test Cases for the Commission Problem
 Guidelines and Observations

40
Equivalence Class Test Cases for the
Triangle Problem
 Outputs: Not a Triangle, Scalene, Isosceles, Equilateral
 Easier to identify output (range) equivalence classes
 R1 = {<a, b, c> : the triangle with sides a, b, and c is equilateral}
 R2 = {<a, b, c> : the triangle with sides a, b, and c is isosceles}
 R3 = {<a, b, c> : the triangle with sides a, b, and c is scalene}
 R4 = {<a, b, c> : sides a, b, and c do not form a triangle}

Test Case a b c Expected Output


OE1 5 5 5 Equilateral
OE2 2 2 3 Isosceles
OE3 3 4 5 Scalene
OE4 4 1 2 Not a Triangle

41
Equivalence Class Test Cases for the
Triangle Problem
 Input (domain) equivalence classes
D1 = {<a, b, c> : a = b = c}
D2 = {<a, b, c> : a = b, a ≠ c}
D3 = {<a, b, c> : a = c, a ≠ b}
D4 = {<a, b, c> : b = c, a ≠ b}
D5 = {<a, b, c> : a ≠ b, a ≠ c, b ≠ c}
// D6 = {<a, b, c> : a ≥ b + c}
D6’ = {<a, b, c> : a = b + c}
D6’’ = {<a, b, c> : a > b + c}
// D7 = {<a, b, c> : b ≥ a + c}
D7’ = {<a, b, c> : b = a + c}
D7’’ = {<a, b, c> : b > a + c}
// D8 = {<a, b, c> : c ≥ a + b}
D8’ = {<a, b, c> : c = a + b}
D8’’ = {<a, b, c> : c > a + b}

42
Agenda
 Boundary Value Testing
 Boundary Value Analysis
 Generalizing Boundary Value Analysis
 Limitations of Boundary Value Analysis
 Robustness Testing
 Worst Case Testing
 Special Value Testing
 Examples
 Test Cases for the Triangle Problem
 Test Cases for the NextDate Problem
 Test Cases for the Commission Problem
 Guidelines for Boundary value Testing
 Equivalence Class Testing
 Equivalence Classes
 Weak Equivalence Class Testing
 Strong Equivalence Class Testing
 Traditional Equivalence Class Testing
 Equivalence Class Test Cases for the Triangle Problem
 Equivalence Class Test Cases for the NextDate Function
 Equivalence Class Test Cases for the Commission Problem
 Guidelines and Observations

43
Equivalence Class Test Cases for the
NextDate Function
 Input variables
 1 ≤ month ≤ 12
 1 ≤ day ≤ 31
 1812 ≤ year ≤ 2012
 Traditional approach
 Valid equivalence classes
 M1 = { month : 1 ≤ month ≤ 12 } Case ID Month Day Year Expected Output
 D1 = { day : 1 ≤ day ≤ 31 } TE1 6 15 1912 6/16/1912
TE2 -1 15 1912 invalid input
 Y1 = { year : 1812 ≤ year ≤ 2012 }
TE3 13 15 1912 invalid input
 Invalid equivalence classes TE4 6 -1 1912 invalid input
 M2 = { month : month < 1 } TE5 6 32 1912 invalid input
TE6 6 15 1811 invalid input
 M3 = { month : month > 12 } TE7 6 15 2013 invalid input
 D2 = { day : day < 1 }
 D3 = { day : day >31 }
 Y2 = { year : year < 1812 }
 Y3 = {year : year > 2012 }

44
Equivalence Class Test Cases for the
NextDate Function
 Traditional approach is deficient because it “treats” the
elements of a class at the valid/invalid level
 Different approach: What must be done to an input date?
M1 = { month: month has 30 days }
M2 = { month: month has 31 days }
M3 = { month: month is February }
D1 = { day: 1 ≤ day ≤ 28 }
D2 = { day: day = 29 }
D3 = { day: day = 30 }
D4 = { day: day = 31 }
Y1 = { year: year = 1900 }
Y2 = { year: 1812 ≤ year ≤ 2012 AND (year ≠ 1900)
AND (year mod 4 = 0) }
Y3 = { year: 1812 ≤ year ≤ 2012 AND (year mod 4 ≠ 0) }
Not a perfect set of equivalence classes!!!

45
Equivalence Class Test Cases for the
NextDate Function
Weak equivalence class test cases
Case ID Month Day Year Expected Output
WE1 6 14 1900 6/15/1900
WE2 7 29 1912 7/30/1912
WE3 2 30 1913 invalid input
WE4 6 31 1900 invalid input

Strong equivalence class test cases


Case ID Month Day Year Expected Output Case ID Month Day Year Expected Output
SE1 6 14 1900 6/15/1900 SE19 7 30 1900 7/31/1900
SE2 6 14 1912 6/15/1912 SE20 7 30 1912 7/31/1912
SE3 6 14 1913 6/15/1913 SE21 7 30 1913 7/31/1913
SE4 6 29 1900 6/30/1900 SE22 7 31 1900 08/01/1900
SE5 6 29 1912 6/30/1912 SE23 7 31 1912 08/01/1912
SE6 6 29 1913 6/30/1913 SE24 7 31 1913 08/01/1913
SE7 6 30 1900 07/01/1900 SE25 2 14 1900 2/15/1900
SE8 6 30 1912 07/01/1912 SE26 2 14 1912 2/15/1912
SE9 6 30 1913 07/01/1913 SE27 2 14 1913 2/15/1913
SE10 6 31 1900 ERROR SE28 2 29 1900 ERROR
SE11 6 31 1912 ERROR SE29 2 29 1912 03/01/1912
SE12 6 31 1913 ERROR SE30 2 29 1913 ERROR
SE13 7 14 1900 7/15/1900 SE31 2 30 1900 ERROR
SE14 7 14 1912 7/15/1912 SE32 2 30 1912 ERROR
SE15 7 14 1913 7/15/1913 SE33 2 30 1913 ERROR
SE16 7 29 1900 7/30/1900 SE34 2 31 1900 ERROR
SE17 7 29 1912 7/30/1912 SE35 2 31 1912 ERROR
SE18 7 29 1913 7/30/1913 SE36 2 31 1913 ERROR

46
Agenda
 Boundary Value Testing
 Boundary Value Analysis
 Generalizing Boundary Value Analysis
 Limitations of Boundary Value Analysis
 Robustness Testing
 Worst Case Testing
 Special Value Testing
 Examples
 Test Cases for the Triangle Problem
 Test Cases for the NextDate Problem
 Test Cases for the Commission Problem
 Guidelines for Boundary value Testing
 Equivalence Class Testing
 Equivalence Classes
 Weak Equivalence Class Testing
 Strong Equivalence Class Testing
 Traditional Equivalence Class Testing
 Equivalence Class Test Cases for the Triangle Problem
 Equivalence Class Test Cases for the NextDate Function
 Equivalence Class Test Cases for the Commission Problem
 Guidelines and Observations

47
Equivalence Class Test Cases for the
Commission Problem
 Input Domain Equivalence Classes
 Lock
 L1 = { lock: 1 ≤ lock ≤ 70 }
 L2 = { lock: lock < 1 }
 L3 = { lock: lock > 70 }
 Stock
 S1 = { stock: 1 ≤ stock ≤ 80 }
 S2 = { stock: stock < 1 }
 S3 = { stock: stock > 80 }
 Barrel
 B1 = { barrel: 1 ≤ barrel ≤ 90 }
 B2 = { barrel: barrel < 1 }
 B3 = { barrel: barrel > 90 }

48
Equivalence Class Test Cases for the
Commission Problem
Strong Input Domain Equivalence Class Test Cases
Test Case locks stocks barrels sales commission
SE1 35 40 45 3900 640
SE2 35 40 0 ERROR ERROR
SE3 35 40 91 ERROR ERROR
SE4 35 0 45 ERROR ERROR
SE5 35 0 0 ERROR ERROR
SE6 35 0 91 ERROR ERROR
Weak Input Domain Equivalence Class Test Cases SE7 35 81 45 ERROR ERROR
Test Case locks stocks barrels sales commission SE8 35 81 0 ERROR ERROR
WE1 35 40 45 3900 640 SE9 35 81 91 ERROR ERROR
WE2 0 0 0 ERROR ERROR SE10 0 40 45 ERROR ERROR
WE3 71 81 91 ERROR ERROR SE11 0 40 0 ERROR ERROR
SE12 0 40 91 ERROR ERROR
SE13 0 0 45 ERROR ERROR
SE14 0 0 0 ERROR ERROR
SE15 0 0 91 ERROR ERROR
SE16 0 81 45 ERROR ERROR
SE17 0 81 0 ERROR ERROR
SE18 0 81 91 ERROR ERROR
SE19 71 40 45 ERROR ERROR
SE20 71 40 0 ERROR ERROR
SE21 71 40 91 ERROR ERROR
SE22 71 0 45 ERROR ERROR
SE23 71 0 0 ERROR ERROR
SE24 71 0 91 ERROR ERROR
SE25 71 81 45 ERROR ERROR
SE26 71 81 0 ERROR ERROR
SE27 71 81 91 ERROR ERROR

49
Equivalence Class Test Cases for the
Commission Problem
 sales = 45 x locks + 30 x stocks + 25 x barrels
 L1 = { <lock, stock, barrel> : sales ≤ 1000 }
 L2 = { <lock, stock, barrel> : 1000 < sales ≤
1800 }
 L3 = { <lock, stock, barrel> : sales > 1800 }
Output Range Equivalence Class Test Cases

Test Case locks stocks barrels sales commission


OR1 5 5 5 500 50
OR2 15 15 15 1500 175
OR3 25 25 25 2500 360

50
Agenda
 Boundary Value Testing
 Boundary Value Analysis
 Generalizing Boundary Value Analysis
 Limitations of Boundary Value Analysis
 Robustness Testing
 Worst Case Testing
 Special Value Testing
 Examples
 Test Cases for the Triangle Problem
 Test Cases for the NextDate Problem
 Test Cases for the Commission Problem
 Guidelines for Boundary value Testing
 Equivalence Class Testing
 Equivalence Classes
 Weak Equivalence Class Testing
 Strong Equivalence Class Testing
 Traditional Equivalence Class Testing
 Equivalence Class Test Cases for the Triangle Problem
 Equivalence Class Test Cases for the NextDate Function
 Equivalence Class Test Cases for the Commission Problem
 Guidelines and Observations

51
Guidelines and Observations
1. The traditional form of equivalence class testing is
generally not as thorough as weak equivalence class
testing, which in turn, is not as thorough as the strong
form of equivalence class testing
2. The only time it makes sense to use the traditional
approach is when the implementation language is not
strongly typed
3. If error conditions are a high priority, we could extend
strong equivalence class testing to include invalid
classes (e.g. commission problem)
4. Equivalence class testing is appropriate when input
data is defined in terms of ranges and sets of discrete
values. This is certainly the case when system
malfunctions can occur for out-of-limit variable values

52
Guidelines and Observations
1. Equivalence class testing is strengthened by a hybrid
approach with boundary value testing. (We can “reuse”
the effort made in defining the equivalence classes)
(e.g. NextDate function)
2. Equivalence class testing is indicated when the
program function is complex. In such cases, the
complexity of the function can help identify useful
equivalence classes, as in the NextDate function
3. Strong equivalence class testing makes a presumption
that the variables are independent when the Cartesian
Product is taken. If there are any dependencies, these
will often generate “error” test cases, as they did in the
NextDate function

53
Guidelines and Observations

1. Several tries may be needed before “the


right” equivalence relation is discovered,
as we saw in the NextDate example. In
other cases, there is an “obvious” or
“natural” equivalence partition. When in
doubt, the best bet is to try to second
guess aspects of any reasonable
implementation

54
Agenda
 Boundary Value Testing
 Boundary Value Analysis
 Generalizing Boundary Value Analysis
 Limitations of Boundary Value Analysis
 Robustness Testing
 Worst Case Testing
 Special Value Testing
 Examples
 Test Cases for the Triangle Problem
 Test Cases for the NextDate Problem
 Test Cases for the Commission Problem
 Guidelines for Boundary value Testing
 Equivalence Class Testing
 Equivalence Classes
 Weak Equivalence Class Testing
 Strong Equivalence Class Testing
 Traditional Equivalence Class Testing
 Equivalence Class Test Cases for the Triangle Problem
 Equivalence Class Test Cases for the NextDate Function
 Equivalence Class Test Cases for the Commission Problem
 Guidelines and Observations

55
References

 Software Testing A Craftsman's Approach


2nd edition, Paul C. Jorgensen, CRC
Press (Chapters 5 and 6)

56

Você também pode gostar