Equivalence Partitioning Tutorial
Definition of Equivalence Partitioning
Equivalence Partitioning is a black-box testing technique (basic test-design technique) that splits the input domain into classes of data. From this data, we can derive test cases.
Test-case design with the help of equivalence partitioning technique has two steps:
1) Identifying the equivalence classes.
2) Defining the test cases.
Example 1 of Equivalence Partitioning
Problem:-
The program reads three integer values from an input dialog. The three values represent the lengths of the sides of a triangle. The program displays a message that states whether the triangle is scalene, isosceles, or equilateral. Remember that a scalene triangle is one where no two sides are equal, whereas an isosceles triangle has two equal sides, and an equilateral triangle has three sides of equal length. Moreover, the angles opposite the equal sides in an isosceles triangle also are equal (it also follows that the sides opposite equal angles in a triangle are equal), and all angles in an equilateral triangle are equal.
(Source: http://www.amazon.com/Art-Software-Testing-Glenford-Myers/dp/0471043281)
Solution:-
As seen in the definition above we have to identify equivalence classes and define test cases based on those classes.
Equivalence Classes for the triangle problem
Test Case #
|
Side1
|
Side2
|
Side3
|
Expected Output
|
1
|
5
|
5
|
5
|
Equilateral
|
Test Cases (Valid) for Isosceles Triangle
Test Case #
|
Side1
|
Side2
|
Side3
|
Expected Output
|
1
|
2
|
2
|
3
|
Isosceles
|
2
|
2
|
3
|
2
|
Isosceles
|
3
|
3
|
2
|
2
|
Isosceles
|
Test Cases (Valid) for Scalene Triangle
Test Case #
|
Side1
|
Side2
|
Side3
|
Expected Output
|
1
|
3
|
4
|
6
|
Scalene
|
2
|
3
|
6
|
4
|
Scalene
|
3
|
4
|
3
|
6
|
Scalene
|
Test Cases (Invalid) Not a Triangle
Test Case #
|
Side1
|
Side2
|
Side3
|
Expected Output
|
1
|
3
|
1
|
2
|
Not a triangle
|
2
|
2
|
3
|
1
|
Not a triangle
|
3
|
1
|
2
|
4
|
Not a triangle
|
More solutions to the triangle problem
Example 2 of Equivalence Partitioning
The specifications for a application software system for authenticating expenses claim for motel accommodation for one night includes the following requirements:
The upper limit is $100 for accommodation expenses claims.
Any claims above $100 should be rejected and should cause an error message to be displayed.
Expense amounts should be greater than $0 and an error message should be displayed otherwise.
Test case ID
|
Motel Charge
|
Equivalence class
|
Expected output
|
1
|
65
|
0 < Motel Charge<=100
|
OK
|
2
|
-24
|
Motel Charge <=0
|
Error message
|
3
|
110
|
Motel Charge > 100
|
Error message
|
2 thoughts on “Equivalence Partitioning Tutorial”
Comments are closed.
nice post. thanks.
Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.
kajal hot