Software Testing / Black Box Testing

Understanding Equivalence Partitioning

A tutorial about Understanding Equivalence Partitioning

Tutorial 1 of 5 5 resources in this section

Section overview

5 resources

Black Box Testing is a method of testing where the internal structure/ design/ implementation of the item being tested is not known to the tester.

Understanding Equivalence Partitioning

1. Introduction

Welcome to this tutorial on understanding equivalence partitioning.

Tutorial's Goal

The goal of this tutorial is to guide you through the concept of Equivalence Partitioning, a software testing design technique that simplifies the testing effort.

What you will learn

By the end of this tutorial, you will have a clear understanding of:

  • What equivalence partitioning is.
  • Why it is important.
  • How to apply it in real-world scenarios.

Prerequisites

This is a beginner-friendly tutorial. However, having some basic understanding of software testing would be helpful.

2. Step-by-Step Guide

Equivalence Partitioning is a software testing technique that divides the input data of a software unit into partitions of equivalent data from which test cases can be derived.

Explanation of Concepts

In equivalence partitioning, inputs to the software or system are divided into groups that are expected to exhibit similar behavior, hence reducing the total number of test cases to be developed.

Examples

Think of a system that accepts age as an input field. The valid age range is 18-65. Any age below 18 and above 65 is considered invalid.

Here, we can create three equivalence classes:

  • Invalid equivalence class: Age < 18
  • Valid equivalence class: 18 <= Age <= 65
  • Invalid equivalence class: Age > 65

Best Practices and Tips

  • Always remember that test cases are derived from each partition.
  • Invalid partitions are also important.
  • Each partition should be tested by at least one test case.

3. Code Examples

Unfortunately, equivalence partitioning is a concept used in manual testing, and thus, does not have any code examples. However, it can be used in automated testing scenarios. Here's an example in Python using pytest:

import pytest

def test_age_group():
    assert age_group(17) == 'Invalid'
    assert age_group(18) == 'Adult'
    assert age_group(65) == 'Adult'
    assert age_group(66) == 'Invalid'

In the above example, we are testing an imaginary function age_group, which should return 'Invalid' for ages below 18 and above 65, and 'Adult' for ages between 18 and 65.

4. Summary

In this tutorial, we have covered the concept of equivalence partitioning, a software testing technique that groups the input data of a software unit into partitions of equivalent data, from which test cases can be derived. We also looked at an example of how to apply this concept.

For further learning, explore boundary value analysis, which is similar to equivalence partitioning and often used together.

5. Practice Exercises

Now, let's put what we have learned into practice. Here are some exercises for you:

  1. Consider a system that accepts a percentage as input. The valid range is 0-100. Create three equivalence classes for this system.
  2. Consider a login system that accepts a password with a length of 6-12 characters. Create the equivalence classes for this system.

Solutions

  1. For a system that accepts a percentage as input, the equivalence classes would be:

    • Invalid: Percentage < 0
    • Valid: 0 <= Percentage <= 100
    • Invalid: Percentage > 100
  2. For a login system that accepts a password with a length of 6-12 characters, the equivalence classes would be:

    • Invalid: Length < 6
    • Valid: 6 <= Length <= 12
    • Invalid: Length > 12

These exercises are aimed at helping you understand how to create equivalence classes. As a tip, remember to always include both valid and invalid classes when creating your partitions.

Need Help Implementing This?

We build custom systems, plugins, and scalable infrastructure.

Discuss Your Project

Related topics

Keep learning with adjacent tracks.

View category

HTML

Learn the fundamental building blocks of the web using HTML.

Explore

CSS

Master CSS to style and format web pages effectively.

Explore

JavaScript

Learn JavaScript to add interactivity and dynamic behavior to web pages.

Explore

Python

Explore Python for web development, data analysis, and automation.

Explore

SQL

Learn SQL to manage and query relational databases.

Explore

PHP

Master PHP to build dynamic and secure web applications.

Explore

Popular tools

Helpful utilities for quick tasks.

Browse tools

JWT Decoder

Decode and validate JSON Web Tokens (JWT).

Use tool

QR Code Generator

Generate QR codes for URLs, text, or contact info.

Use tool

Image Converter

Convert between different image formats.

Use tool

Open Graph Preview Tool

Preview and test Open Graph meta tags for social media.

Use tool

Countdown Timer Generator

Create customizable countdown timers for websites.

Use tool

Latest articles

Fresh insights from the CodiWiki team.

Visit blog

AI in Drug Discovery: Accelerating Medical Breakthroughs

In the rapidly evolving landscape of healthcare and pharmaceuticals, Artificial Intelligence (AI) in drug dis…

Read article

AI in Retail: Personalized Shopping and Inventory Management

In the rapidly evolving retail landscape, the integration of Artificial Intelligence (AI) is revolutionizing …

Read article

AI in Public Safety: Predictive Policing and Crime Prevention

In the realm of public safety, the integration of Artificial Intelligence (AI) stands as a beacon of innovati…

Read article

AI in Mental Health: Assisting with Therapy and Diagnostics

In the realm of mental health, the integration of Artificial Intelligence (AI) stands as a beacon of hope and…

Read article

AI in Legal Compliance: Ensuring Regulatory Adherence

In an era where technology continually reshapes the boundaries of industries, Artificial Intelligence (AI) in…

Read article

Need help implementing this?

Get senior engineering support to ship it cleanly and on time.

Get Implementation Help