Equivalence partitioning is the process of defining
the optimum number of tests by:
- Reviewing documents such as the Functional Design
Specification and Detailed Design Specification, and identifying each input
condition within a function
- Selecting input data that is representative of all
other data that would likely invoke the same process for that particular
condition
Defining
Tests
A number of items
must be considered when determining the tests using the equivalence
partitioning method, including:
- All valid input data for a given condition are
likely to go through the same process
- Invalid data can go through various processes and
need to be evaluated more carefully. For example
- A blank entry may be treated differently than an incorrect entry
- A value that is less than a range of values may be treated differently than a value that is greater
- If there is more than one error condition within a particular function, one error may override the other, which means the subordinate error does not get tested unless the other value is valid
Defining Test Cases
Create test cases
that incorporate each of the tests. For valid input, include as many
tests as possible in one test case. For invalid input, include only one
test in a test case in order to isolate the error. Only the invalid input
test condition needs to be evaluated in such tests, because the valid condition
has already been tested.
EXAMPLE OF
EQUIVALENCE PARTITIONING
Conditions to be
Tested
The following input
conditions will be tested:
For the first three digits of all social insurance
(security) numbers, the minimum number is 111 and the maximum number is
222
For the fourth and fifth digits of all social
insurance (security) numbers, the minimum number is 11 and the maximum number
is 99
Defining Tests
Identify the input
conditions and uniquely identify each test, keeping in mind the items to
consider when defining tests for valid and invalid data.
The tests for these
conditions are:
The first three
digits of the social insurance (security) number are:
1. =
or > 111 and = or < 222, (valid input),
2. <
111, (invalid input, below the range),
3. >
222, (invalid input, above the range),
4.
blank, (invalid input, below the range, but may be treated
differently).
The fourth and fifth digits of the social insurance
(security) number are:
5. =
or > 11 and = or < 99, (valid input),
6. <
11, (invalid input, below the range),
7. >
99, (invalid input, above the range),
8.
blank, (invalid input, below the range, but may be treated
differently).
Using equivalence
partitioning, only one value that represents each of the eight equivalence
classes needs to be tested.
Defining Test Cases
After identifying
the tests, create test cases to test each equivalence class, (i.e., tests 1
through 8).
Create one test case
for the valid input conditions, (i.e., tests 1 and 5), because the two
conditions will not affect each other.
Identify separate
test cases for each invalid input, (i.e., tests 2 through 4 and tests 6 through
8). Both conditions specified, (i.e., condition 1 - first three digits,
condition 2 - fourth and fifth digits), apply to the social insurance (security)
number. Since equivalence partitioning is a type of black-box testing,
the tester does not look at the code and, therefore, the manner in which the
programmer has coded the error handling for the social insurance (security)
number is not known. Separate tests are used for each invalid
input, to avoid masking the result in the event one error takes priority over
another. For example, if only one error message is displayed at one time,
and the error message for the first three digits takes priority, then testing
invalid inputs for the first three digits and the fourth and fifth digits
together, does not result in an error message for the fourth and fifth digits.
In tests B through G, only the results for the invalid input need to be
evaluated, because the valid input was tested in test case A.
Suggested test
cases:
Test Case A - Tests 1 and 5, (both are valid,
therefore there is no problem with errors)
Test Case B - Tests 2 and 5, (only the first one is
invalid, therefore the correct error should be produced)
Test Case C - Tests 3 and 5, (only the first one is
invalid, therefore the correct error should be produced)
Test Case D - Tests 4 and 5, (only the first one is
invalid, therefore the correct error should be produced)
Test Case E - Tests 1 and 6, (only the second one
is invalid, therefore the correct error should be produced)
Test Case F - Tests 1 and 7, (only the second one
is invalid, therefore the correct error should be produced)
Test Case G - Tests 1 and 8, (only the second one is
invalid, therefore the correct error should be produced)
Other Types of
Equivalence Classes
The process of
equivalence partitioning also applies to testing of values other than numbers.
Consider the following types of equivalence classes:
- A valid group versus an invalid group, (e.g., names
of employees versus names of individuals who are not employees)
- A valid response to a prompt versus an invalid
response, (e.g., Y versus N and all non-Y responses)
- A valid response within a time frame versus an
invalid response outside of the acceptable time frame, (e.g., a date within a
specified range versus a date less than the range and a date greater than the
range)