En - Domain Testing
En - Domain Testing
1
Domain Testing
EQUIVALENCE partitioning, equivalence analysis,
boundary analysis
Fundamental question or goal:
This confronts the problem that there are too many
test cases for anyone to run. This is a stratified
sampling strategy that provides a rationale for
selecting a few test cases from a huge population .
In domain testing, we
partition a domain
into sub-domains (equivalence classes)
and then test
using values from each sub-domain.
2
General approach
Divide the set of possible values of a field into
subsets , pick values to represent each subset.
7KHJRDOLVWRILQGD³ best representative ´IRU
each subset, and to run tests with these
representatives. Best representatives of
ordered fields will typically be boundary values .
Multiple variables : combine tests of several
³EHVWUHSUHVHQWDWLYHV´ and find a defensible
way to sample from the set of combinations.
3
What is equivalence?
4 views of what makes values equivalent. Each
has practical implications
Intuitive Similarity : two test values are equivalent
if they are so similar to each other that it seems
pointless to test both
Specified As Equivalent: two test values are
equivalent if the specification says that the program
handles them in the same way
Equivalent Paths: two test values are equivalent if
they would drive the program down the same path
(e.g. execute the same branch of an IF)
Risk - Based : two test values are equivalent if, given
your theory of possible error, you expect the same
result from each
4
Equivalence Partitioning
If a test case in an equivalence class
detects an error , then any other test
case in that class should also detect
the error.
If a test case in an equivalence class
does not detect an error , then any
other test case in that class should
not detect an error .
5
What should we do ?
Program specifications should
identify both valid and invalid
inputs for a program.
VALID EQUIVALENCE CLASSES are
chosen to represent valid inputs.
INVALID EQUIVALENCE CLASSES
are chosen to represent invalid
inputs.
6
Test which values from the
equivalence class?
The program is more likely to fail at a boundary?
Suppose program design :
INPUT < 10 result: Error message
10 <= INPUT < 25 result: Print "hello"
25 <=INPUT result: Error message
Some error types
Program doesn't like numbers
Any number will do
Inequalities mis - specified (e.g. INPUT <= 25 instead
of < 25)
Detect only at boundary
Boundary value mistyped (e.g. INPUT < 25,
transposition error)
Detect at boundary and any other value that will be handled
incorrectly
7
Boundary or Non - Boundary ?
Boundary values (here, test at 25) catch
all three errors
Non - boundary values (consider 53) may
catch only one of the three errors
8
Guidelines
If an input condition specifies a
UDQJHRIYDOXHV H
FRXQWFDQEHIURP
identify one valid equivalence
class (1<item count<999) and
two invalid equivalence classes
(item count<1 and item
count>999).
10
Guidelines
If an input condition specifies the
number of values HJ³RQ
through six owners can be listed
IRUWKHDXWRPRELOH´ identify one
valid equivalence class and two
invalid equivalence classes (no
owners and more than six
owners).
11
Guidelines
If an input condition specifies a set of
input values and there is reason to
believe that each is handled differently
by the program
([S³W\SHRIYHKLFOHP
BUS, TRUCK, TAXI - CAB,
PASSENGER, or MOTORCYCLE
Identify a valid equivalence class for
each and one invalid equivalence
class ( HJ³75$,/(5´
12
Guidelines
If an input condition specifies a
³ must be ´VLWXDWLRQ H
character of the identifier must
EHDOHWWHU´ one valid
LGHQ
equivalence class (it is a letter)
and one invalid equivalence class
(it is not a letter).
13
Guidelines
If there is any reason to believe
that elements in an equivalence
class are not handled in an
identical manner by the program,
split the equivalence class into
two or more smaller equivalence
classes
14
Which one ?
A member of an equivalence class is a best
representative (relative to a potential error)
if no other member of the class is more
likely to expose that error than the best
representative.
Boundary values are often best representatives
We can have best representatives that are not
boundary values
We can have best representatives in non -
ordered domains
15
Selecting test cases
Choose at least one test case from each
class identified.
For valid classes, choose test cases to cover
as many equivalence classes as possible ,
until all valid classes have been covered.
For invalid classes, choose test cases so
that each covers one and only one invalid
class, until all classes are covered.
16