Aller au contenu principal

Test Case Design Technique: Equivalence Partitioning

Overview

Equivalence Partitioning (EP) is a black-box test design technique that divides input data into partitions or classes where the system is expected to behave similarly. By identifying these equivalence classes, testers can reduce the number of test cases while maintaining effective coverage.

Instead of testing every possible input, EP helps choose representative values from each class, assuming if one value in the class works, the rest will too.


Why Use Equivalence Partitioning?

  • Reduces redundancy in test cases
  • Improves test efficiency by covering more logic with fewer tests
  • Focuses on valid and invalid input handling
  • Enhances clarity in requirement-based testing

How It Works

  1. Analyze input fields or parameters.
  2. Identify sets of valid and invalid data.
  3. Group data into equivalence classes:
    • Valid classes: Inputs that should be accepted
    • Invalid classes: Inputs that should be rejected
  4. Select one representative value from each class to test.

Simple Example: Age Input Field

Imagine a form that accepts user age between 18 and 65 inclusive.

Step 1: Identify Equivalence Classes

Class TypeRangeDescription
Valid18 to 65Acceptable age range
Invalid< 18Too young
Invalid> 65Too old
InvalidNon-numerice.g., "abc", "!@#"

Step 2: Choose Test Inputs

You only need to test one representative value from each class.

ClassRepresentative ValueExpected Result
Valid30Accepted
Invalid (<18)17Rejected - too young
Invalid (>65)70Rejected - too old
Invalid (text)"abc"Rejected - not a number

Real-World Example: Password Length Validation

Requirement: Password must be between 8 and 16 characters.

Class TypeRangeExample ValueExpected Result
Valid8–16 chars"Password123"Accepted
Invalid< 8 chars"Pass1"Rejected
Invalid> 16 chars"VeryLongPassword!"Rejected

By selecting only one value per class, you ensure broad functional coverage with minimal test cases.


Combining with Other Techniques

Equivalence Partitioning is often combined with:

  • Boundary Value Analysis (BVA) for edge conditions
  • Decision Table Testing for complex rules
  • State Transition Testing for dynamic systems

Best Practices

  • Clearly define the valid/invalid criteria from requirements.
  • Document each equivalence class and rationale.
  • Cover at least one test per partition to ensure logic is verified.
  • Use EP early in test design to save effort later.

Summary

Equivalence Partitioning helps testers focus on the most meaningful test inputs by dividing data into logical groups. It reduces test suite size without compromising quality and is especially useful for input validation, form fields, and API parameters.

"Don’t test everything. Test smartly. Equivalence Partitioning is about maximum coverage with minimum effort."