Equivalence Partitioning - Multiple Choice Questions

1. What is an equivalence partition (also known as an equivalence class)?

a) A set of test cases for testing classes of objects.
b) An input or output range of values such that only one value in the range becomes a test case.
c) An input or output range of values such that each value in the range becomes a test case.
d) An input or output range of values such that every tenth value in the range becomes a test case.


2. One of the fields on a form contains a text box which accepts numeric values in the range of 18 to 25.
Indentify the invalid Equivalence class

a) 17
b) 19
c) 24
d) 21


3. In a Examination a candidate has to score minimum of 24 marks inorder to clear the exam. The maximum that he can score is 40 marks. Identify the Valid Equivalence values if the student clears the exam.

a) 22,23,26
b) 21,39,40
c) 29,30,31
d) 0,15,22


4. One of the fields on a form contains a text box which accepts alpha numeric values. Identify the Valid 

Equivalence class
a) BOOK
b) Book
c) Boo01k
d) book


5. The Switch is switched off once the temperature falls below 18 and then it is turned on when the temperature is more than 21. When the temperature is more than 21. Identify the Equivalence values which belong to the same class.

a) 12,16,22
b) 24,27,17
c) 22,23,24
d) 14,15,19


6. A program validates a numeric field as follows: 
values less than 10 are rejected, values between 10 and 21 are accepted, values greater than or equal to 22 are rejected. which of the following input values cover all of the equivalence partitions?

a. 10,11,21
b. 3,20,21
c. 3,10,22
d. 10,21,22

7. The specification: an integer field shall contain values from and including 1 to and including 12 (number of the month). Which equivalence class partitioning is correct?

a) Less than 1, 1 through 12, larger than 12
b) Less than 1, 1 through 11, larger than 12
c) Less than 0, 1 through 12, larger than 12
d) Less than 1, 1 through 11, and above


8. A program validates a numeric field as follows: values less than 10 are rejected, values between 10 and 21 are accepted, values greater than or equal to 22 are rejected. Which of the following covers the MOST boundary values?

a. 9,10,11,22
b. 9,10,21,22
c. 10,11,21,22
d. 10,11,20,21


9. In a system designed to work out the tax to be paid:
An employee has £4000 of salary tax free. The next £1500 is taxed at 10%. The next £28000 is taxed at 22%. Any further amount is taxed at 40%. Which of these groups of numbers would fall into the same equivalence class?

a) £4800; £14000; £28000
b) £5200; £5500; £28000
c) £28001; £32000; £35000
d) £5800; £28000; £32000


10. Order numbers on a stock control system can range between 10000 and 99999 inclusive. Which of the following inputs might be a result of designing tests for only valid equivalence classes and valid boundaries:

a) 1000, 5000, 99999
b) 9999, 50000, 100000
c) 10000, 50000, 99999
d) 10000, 99999
e) 9999, 10000, 50000, 99999, 10000

11. Equivalence partitioning is:

a. A black box testing technique used only by developers
b. A black box testing technique than can only be used during system testing
c. A black box testing technique appropriate to all levels of testing
d. A white box testing technique appropriate for component testing


12. Which of the following is a valid collection of equivalence classes for the following problem: An integer field shall contain values from and including 1 to and including 15

a. Less than 1, 1 through 15, more than 15
b. Negative numbers, 1 through 15, above 15
c. Less than 1, 1 through 14, more than 15
d. Less than 0, 1 through 14, 15 and more


13. Which of the following is a valid collection of equivalence classes for the following problem: Paying with credit cards shall be possible with Visa, Master and Amex cards only.

a. Visa, Master, Amex;
b. Visa, Master, Amex, Diners, Keycards, and other option
c. Visa, Master, Amex, any other card, no card
d. No card, other cards, any of Visa – Master – Amex


14. Given the following specification, which of the following values for age are in the SAME equivalence partition? If you are less than 18, you are too young to be insured. Between 18 and 30 inclusive, you will receive a 20% discount. Anyone over 30 is not eligible for a discount.

A 17, 18, 19.
B 29, 30, 31.
C 18, 29, 30.
D 17, 29, 31.


15. One of the fields on a form contains a text box which accepts alphabets in lower or upper case.Indentify the invalid Equivalence class value.

a. CLASS
b. cLASS
c. CLass
d. CLa01ss


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 Cases (Valid) for Equilateral Triangle
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

Solution 1

Solution 2

Solution 3

Solution 4


Example 2 of Equivalence Partitioning

The specifications for a application software system for authenticating expenses claim for motel accomodation for one night includes the following requirements:

Upper limit is $100 for accomodation 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.

Designing test cases
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

Another Example of Equivalence Partition



Advantages of Equivalence Partitioning

It decreases the scope of extensive testing to a well-defined set of test procedures i.e. it reduces the number of required test cases by identifying classes of data. This in a way also helps to reduce redundant test cases.

Drawbacks of Equivalence Partitioning

The resultant test procedures do not include other types of tests that may have a high likelihood of finding an error. e.g. suppose for some problem we might need to define equivalence classes for infinite number of days.

first day of month

middle day of month

last day of month

last day of year

28th of February, non-leap year

28th of February, leap year

29th of February, leap year

In this way we surely bring down the number of test cases but equivalence partitioning may not check unexpected input as 32nd of November.


Equivalence Partitioning


  • Equivalence partitioning(EP) is a specification-based or black-box technique.
  • It can be applied at any level of testing and is often a good technique to use first.
  • The idea behind this technique is to divide (i.e. to partition) a set of test conditions into groups or sets that can be considered the same (i.e. the system should handle them equivalently), hence ‘equivalence partitioning’. Equivalence Partitions are also known as equivalence classes – the two terms mean exactly the same thing.
  • In equivalence-partitioning technique we need to test only one condition from each partition. This is because we are assuming that all the conditions in one partition will be treated in the same way by the software. If one condition in a partition works, we assume all of the conditions in that partition will work, and so there is little point in testing any of these others. Similarly, if one of the conditions in a partition does not work, then we assume that none of the conditions in that partition will work so again there is little point in testing any more in that partition.
For example, a savings account in a bank has a different rate of interest depending on the balance in the account. In order to test the software that calculates the interest due, we can identify the ranges of balance values that earn the different rates of interest. For example, 3% rate of interest is given if the balance in the account is in the range of $0 to $100, 5% rate of interest is given if the balance in the account is in the range of $100 to $1000, and 7% rate of interest is given if the balance in the account is $1000 and above, we would initially identify three valid equivalence partitions and one invalid partition as shown below.

Equivalence partitioning

In the above example we have identified four partitions, even though the specification mentioned only three. This shows a very important task of the tester that is a tester should not only test what is in the specification, but should also think about things that haven’t been specified. In this case we have thought of the situation where the balance is less than zero. We haven’t (yet) identified an invalid partition on the right, but this would also be a good thing to consider. In order to identify where the 7% partition ends, we would need to know what the maximum balance is for this account (which may not be easy to find out). In our example we have left this open for the time being. Note that non-numeric input is also an invalid partition (e.g. the letter ‘a’) but we discuss only the numeric partitions for now. We have made an assumption here about what the smallest difference is between two values. We have assumed two decimal places, i.e. $100.00, but we could have assumed zero decimal places (i.e. $100) or more than two decimal places (e.g. $100.0000) In any case it is a good idea to state your assumptions – then other people can see them and let you know if they are correct or not. When designing the test cases for this software we would ensure that all the three valid equivalence partitions are covered once, and we would also test the invalid partition at least once. So for example, we might choose to calculate the interest on balances of-$10.00, $50.00, $260.00 and $1348.00. If we hadn’t specifically identified these partitions, it is possible that at least one of them could have been missed at the expense of testing another one several times over. Note that we could also apply equivalence partitioning to outputs as well. In this case we have three interest rates: 3%, 5% and 7%, plus the error message for the invalid partition (or partitions). In this example, the output partitions line up exactly with the input partitions. How would someone test this without thinking about the partitions? A inexperienced tester (let’s call him Robbin) might have thought that a good set of tests would be to test every $50. That would give the following tests: $50.00, $100.00, $150.00, $200.00, $250.00, … say up to $800.00 (then Robbin would have got tired of it and thought that enough tests had been carried out). But look at what Robbin has tested: only two out of four partitions! So if the system does not correctly handle a negative balance or a balance of $1000 or more, he would not have found these defects – so the naive approach is less effective than equivalence partitioning. At the same time, Robbin has four times more tests (16 tests versus our four tests using equivalence partitions), so he is also much less efficient. This is why we say that using techniques such as this makes testing both more effective and more efficient. Note that when we say a partition is ‘invalid’, it doesn’t mean that it represents a value that cannot be entered by a user or a value that the user isn’t supposed to enter. It just means that it is not one of the expected inputs for this particular field.