# Equivalence Class Partitioning

## Overview

In this tutorial, we will learn about Equivalence Class Partitioning. In the approach, the domain of test input values to a software application is partitioned into a set of equivalence classes. This partitioning is done such that the application’s behavior under test(AUT) is similar for every input data belonging to the same equivalence class.

## Equivalence Class Partitioning

Equivalence Class Partitioning(ECP) is a software testing technique that divides the input test data of the AUT(Application Under Test) into a set of equivalence classes. An equivalence class represents a set of valid or invalid states for the input values/conditions.

Equivalence Classes are derived from the system specifications like user requirements, user stories, etc. Equivalence Classes provide logical partitioning of the input test data. Each partition has at least one of equivalent data from which test cases can be derived.

## Creating Equivalence Classes

The main idea behind defining the equivalence classes is that testing the code with any value belonging to an equivalence class is as good as testing the application with any other value belonging to that equivalence class partition.

For example, Consider a web page with an input field that accepts numbers.

The specification for the field is: the field is supposed to accept a number from 1 to 100; the equivalence class partitions are as follows:

**Valid Equivalence Class partition:**

- One class where the input is between 1 and 100( inclusive of 1 and 100).

For example, Any number in [1, 100]

27

**Invalid Equivalence Class partitions:**

- One class where the input is less than 1( < 1).

For example: -5

- One class where the input is greater than 100( > 100).

For example: 160

## Example

Let’s look at another example: Consider an input field that allows an input number for the student’s age. We can assume values from 0 to 100 for the age data field. The three equivalence classes are as follows:

- Set of negative numbers as the age (Β age < 0 )
- Set of numbers in the range of 0 to 100 as the valid age,[0,100]
- Set of numbers larger than 100 ( age > 100 )

The test cases must include representatives for each of the three equivalence classes. A range of values can specify the input data values to a system, then one valid and two invalid equivalence classes should be defined. The possible equivalence class test cases can be:Β Β {-5,15,200}

The ECP technique is used in black box testing to minimize the number of test cases while maintaining adequate test coverage.

More Information

https://en.wikipedia.org/wiki/Black-box_testing