Pull to refresh

Equivalence Classes for QA from the Perspective of Mathematical Analysis

Level of difficultyMedium
Reading time4 min
Views556

Introduction

My name is Kseniia, and I have been in IT for over seven years. In this article, I want to explore the concept of equivalence classes from the perspective of mathematical analysis, a precise science.

I started my career in QA and have read many books on testing. At university, I studied mathematical analysis, where we covered equivalence classes. Testing books also mentioned equivalence classes, but none of them included any formulas. Bridging the gap between these two concepts was quite challenging—but we managed.


Why Does This Matter?

Every testing book emphasizes that the most important aspect of QA is applying test design techniques correctly. However, few books explain how to do this effectively.

The ideal test checklist should include only the necessary tests to make a final decision on a task—no more, no less. Equivalence classes help us achieve this balance.


Equivalence Classes in Mathematical Analysis

An equivalence class is a set of input (or output) data in software that is processed by the same algorithm or leads to the same result. Essentially, it is a range of values that, when input into a program, produce the same outcome.

The simplest equivalence classes in testing are two fundamental types:

  • Positive cases (valid inputs)

  • Negative cases (invalid inputs)

A binary relation RR on a set XX is called an equivalence relation if it satisfies the following properties:

Properties of an Equivalence Relation

  • Reflexivity: x=xx = x (a value is equivalent to itself)

  • Symmetry: If x=yx = y, then y=xy = x

  • Transitivity: If x=yx = y and y=zy = z, then x=zx = z

For example, consider the relation "living in the same city":
✅ Reflexivity: Ivan lives in the same city as himself → ✅ Yes
✅ Symmetry: Ivan lives in the same city as Igor, and Igor lives in the same city as Ivan → ✅ Yes
✅ Transitivity: Ivan lives in the same city as Igor, Igor lives in the same city as Olga, therefore Ivan lives in the same city as Olga → ✅ Yes

However, the relation "being acquainted" is not an equivalence relation because it is not necessarily transitive (i.e., if Ivan knows Igor and Igor knows Olga, Ivan may not necessarily know Olga).

An equivalence class MaM_a is defined as the set of all elements MM that are related to element aa by the equivalence relation RR.


Partitioning a Set into Equivalence Classes

A partition of a set MM into equivalence classes consists of subsets MiM_i, where i∈Ii \in I (a set of indices), satisfying the following conditions:

  • Each subset is non-empty

  • The subsets do not overlap

  • The union of all subsets equals the original set

If this seems confusing—don’t worry! Let's now connect these mathematical concepts to how equivalence classes are used in QA testing.


Equivalence Classes in QA Testing

In QA, we define equivalence classes based on the following principles:
✔ They test the same functionality (a function, module, or system component).
✔ If one representative of an equivalence class fails, others are likely to fail too.
✔ If one representative passes, others are likely to pass too.

Let's Look at an Example

Imagine we have a task to test the conversion of rubles to euros. Let’s apply everything we’ve learned so far—recalling properties, generating equivalence classes, and then verifying these classes against the properties to determine how well we have structured them.


Properties of Equivalence Classes

Step 1: Define the Set for Partitioning

The set consists of all possible numbers that our program can process as input and return as output.

Step 2: Define a Relation

To determine equivalence classes, we need to properly define the relation and check whether it qualifies as an equivalence relation.

For example, we might define the relation as:

  • "Produces an error"

  • "Does not produce an error"

At first glance, two equivalence classes come to mind:

  • Positive numbers as input

  • Negative numbers as input


Step 3: Checking the Equivalence Classes Against Properties

Let’s test whether our two equivalence classes satisfy the required properties:

Non-empty sets – Yes
Distinct sets – Yes (if we input a positive number, no error occurs; if we input a negative number, an error occurs)
No overlapping elements – Yes

🚨 But there's a problem!
The union of positive and negative numbers does not cover all numbers, because we forgot about zero!

This means our partitioning was incorrect—we failed to account for all possible inputs.


Step 4: Creating More Complex Equivalence Relations

We can define a more detailed equivalence relation, such as "Returns a correct result".

To apply this, we need to first determine what constitutes a correct result:

  • Numbers greater than 1

  • Numbers less than 1

  • Errors when entering negative numbers

  • Errors when entering letters instead of numbers

Once we establish this, we divide inputs into equivalence classes and check whether each class satisfies the necessary properties.


What’s Next?

Now, let’s reflect on everything we’ve covered. Mathematics should help us correctly define equivalence classes to reduce the number of errors that arise due to incorrect partitioning. After all, as we already know, corner cases often hide at the boundaries of equivalence classes.

✅ Now we know how to check whether a relation qualifies as an equivalence relation.
✅ Now we know how to verify whether our equivalence classes meet mathematical analysis properties.
✅ Now we just need to start applying this in real-world testing!

Give it a try—once you start using these properties, you’ll get hooked! 😊

Tags:
Hubs:
Total votes 1: ↑1 and ↓0+1
Comments0

Articles