qa-testing

Software Testing Techniques: Equivalence Partitioning & Boundary Value Analysis

Hi, I'm Kitle.

When designing test cases, relying on intuition isn't enough. Today, we'll explore Specification-Based Testing—a methodology where test cases are designed based on the system's functional specifications and menus.


Equivalence Partitioning (EP)

Equivalence Partitioning (or Equivalence Class Partitioning) is based on the idea that if a set of input values leads to the same outcome, they can be treated as a single group (class). It assumes that the system processes all values within a group in the same way.

By dividing the input/output domains into finite, mutually independent sets (equivalence classes) and selecting one representative value from each set, we can significantly reduce the total number of test cases while maintaining effective coverage.


[Example: Grade Calculation System]

School 'A' wants to build a program that automatically assigns grades based on scores:

  • 100–90: A
  • 89–70: B
  • 69–50: C
  • 49–0: D

Using Equivalence Partitioning, we can select representative data as follows:

Range Grade Selected Test Data (Example)
90 ≤ Score ≤ 100 A 95
70 ≤ Score ≤ 89 B 80
50 ≤ Score ≤ 69 C 60
0 ≤ Score ≤ 49 D 30

If scores range from 0 to 100, a brute-force approach would require 101 test cases (0, 1, 2... 100). With Equivalence Partitioning, we reduced this to just 4 cases. However, while efficient, these 4 cases might not catch every potential bug—especially at the edges.


Boundary Value Analysis (BVA)

Research shows that defects are most likely to occur at the edges or boundaries of input ranges rather than in the middle. Boundary Value Analysis focuses on designing test cases that target these specific boundary points to increase the probability of defect detection.

Instead of choosing arbitrary values within a class, BVA selects values at the minimum and maximum limits of each partition.


[Example: Applying BVA]

Continuing from the grading example above, we can apply two different BVA approaches:

  • Two-Value BVA: Select the boundary value and the immediate invalid value outside it.
  • Three-Value BVA (Full Boundary): Select the boundary value and the values immediately to its left and right (e.g., if the boundary is 0, test -1, 0, and 1).
Range Two-Value Approach Three-Value Approach
90 ~ 100 (Grade A) Boundaries: 90, 100
Invalid: 89, 101
89, 90, 91
99, 100, 101
70 ~ 89 (Grade B) Boundaries: 70, 89
Invalid: 69, 90
69, 70, 71
88, 89, 90
Final Unique Values -1, 0, 49, 50, 69, 70, 89, 90, 100, 101 -1, 0, 1, 48, 49, 50, 51, 68, 69, 70... 101

Why Boundary Analysis Matters

Defects often stem from ambiguity in specifications or mistakes in implementation:

  • Specification Ambiguity: "Score 90 or above is A, 70-90 is B." (Is 90 an A or a B?)
  • Implementation Errors: Using > instead of >=, or common "off-by-one" errors in loops (starting an index at 1 instead of 0).

Equivalence Partitioning vs. Boundary Value Analysis

  • Consistency: In EP, different testers might pick different representative values, leading to varied results. In BVA, since we always pick the Min/Max, the results are consistent regardless of who performs the test.
  • The "Invalid Value" Rule: When selecting data, it is crucial to include Invalid Values (e.g., -1 or 101). Even if the UI blocks these inputs, you must verify that the system correctly handles or rejects them.