Recommended resources
The freely available resources this lesson will direct you to.
- Boundary Value Analysis and Equivalence Partitioning: Software Testing Tutorialwww.youtube.com
- Software Testing Tutorial #34 - Equivalence Partitioning in Testingwww.youtube.com
- How to create test cases using Equivalence Partitioning and ...dev.to
- Equivalence class partioning and boundary value analysiswww.testbench.com
Introduction
In our last lesson, we established a strategic framework for testing by exploring the testing pyramid. You learned about the different layers—unit, integration, and end-to-end tests—and understood why a balanced test suite is essential for building high-quality software efficiently. We now have the "what" and "why" of a modern testing strategy.
Today, we transition from strategy to tactics. Knowing you need to write a unit test is one thing; knowing exactly which inputs to test is another. It's impossible to test every conceivable value, so how do you choose a small set of inputs that has the highest probability of finding a bug? This lesson will equip you with two powerful, industry-standard techniques to do just that. We will focus on designing effective test cases using Equivalence Partitioning and Boundary Value Analysis. These methods are the foundation of systematic black-box testing, allowing you to achieve maximum test coverage with minimum effort.
1. The Challenge: An Infinity of Inputs
Imagine a simple input field that accepts an integer. The range of possible integers is, for all practical purposes, infinite. How do you test it? You could try 1, 10, 1000, maybe a negative number like -5. This is random, or "ad-hoc," testing. It might find some bugs, but it's inefficient and leaves huge gaps in your coverage.
The core principle behind professional test design is to move from random testing to a systematic approach. We need a way to intelligently reduce the infinite set of possible tests to a finite, manageable, and effective set. This is where Equivalence Partitioning comes in.
2. Equivalence Partitioning: Divide and Conquer
Equivalence Partitioning (or Equivalence Class Partitioning) is a technique for dividing the input data of a software component into partitions of "equivalent" data. The core assumption is that all values within a single partition will be processed by the application in the same way. Therefore, if you test just one value from a partition, you have effectively tested the entire partition.
This allows us to drastically reduce the number of test cases. Instead of testing thousands of values, we identify a handful of partitions and test one representative from each.
The process involves two main steps:
- Identify valid partitions: These are the sets of inputs that the system is expected to accept and process correctly.
- Identify invalid partitions: These are the sets of inputs that the system should reject.
The following video provides an excellent, detailed explanation using practical examples like an e-commerce discount module and a simple input field.
Software Testing Tutorial #34 - Equivalence Partitioning in Testing
The video "Equivalence Partitioning in Testing" from the Software Testing Mentor channel will walk you through the concept with clear, relatable scenarios.
Please watch the following segments: The introduction explains what equivalence partitioning is and why it's a fundamental test design technique. The e-commerce example demonstrates how to break down a complex set of business rules (discount tiers) into valid and invalid partitions. Pay close attention to how this technique helps minimize test cases while maximizing coverage, a key principle we discussed earlier. The text box example provides a simpler, more direct application of the concept to a UI element.
To visualize this, consider an input field for a One-Time Password (OTP) that must be exactly six digits.

Here, we have partitioned all possible inputs into three groups:
- Invalid Partition 1: Length < 6 digits (e.g.,
9754) - Invalid Partition 2: Length > 6 digits (e.g.,
67545678) - Valid Partition: Length = 6 digits (e.g.,
654757or213309)
By testing one value from each partition, we can be reasonably confident that we've covered the length validation logic.
3. Boundary Value Analysis: Testing at the Edges
Equivalence partitioning is a great start, but experience shows that a disproportionate number of bugs occur at the "edges" or "boundaries" between partitions. For example, if a field accepts numbers from 1 to 100, errors are more likely to happen with inputs like 0, 1, 100, or 101 than with an input like 50.
Boundary Value Analysis (BVA) is a technique designed specifically to target these high-risk boundary values. It's used as a complement to equivalence partitioning. After identifying the partitions, you design test cases specifically for the values at, just below, and just above the boundaries.

These two techniques are almost always used together. The following article provides a clear, step-by-step guide on how to apply both.
How to create test cases using Equivalence Partitioning and ...
This guide from dev.to demonstrates the practical application of both techniques with clear numeric and non-numeric examples.
Please read the article from the beginning, focusing on these sections: Equivalence Partitioning: Read from the heading down to the end of the section. Pay special attention to the username registration example, which shows how to handle multiple input conditions and explains the important rule of testing invalid partitions individually. Boundary Value Analysis: Continue reading from the heading to the end of the article. This section clearly defines how to derive boundary values from your partitions and introduces the concepts of 2-value and 3-value BVA.
4. A Combined, Practical Example
Let's put it all together. The real power of these techniques becomes evident when dealing with multiple conditions. As a developer, you frequently encounter logic that depends on several inputs working in concert.
Equivalence class partioning and boundary value analysis
The article from TestBench provides a more complex example that mirrors real-world scenarios you might encounter.
Please read Example 2, which involves calculating flight ticket prices based on passenger age and booking class. Notice how equivalence classes and boundary values are determined for both inputs, leading to a comprehensive set of test cases that cover the interactions between them. This demonstrates how to scale the approach beyond a single input field.
5. Practical Application: Designing Your Test Cases
Now it's time to apply these techniques yourself. This exercise will help you translate the theory into a practical skill you can use immediately in your work.
Scenario:
You are testing a new feature in your Spring Boot application. There is a REST API endpoint, POST /promotions, that accepts a JSON payload to create a new promotion. The payload has a field called discountPercentage. The business requirement is that this field must be an integer between 10 and 90, inclusive.
Your Task:
Design a set of test cases for the discountPercentage field using a combination of Equivalence Partitioning and Boundary Value Analysis. Create a table with the following columns:
| Test Case ID | Input Value | Technique | Expected Outcome |
|---|---|---|---|
| ... | ... | ... | ... |
For "Expected Outcome," you can simply state "Success" (for valid inputs) or "Error" (for invalid inputs).
Think about all possible partitions: valid numbers, numbers outside the range, different data types, etc. Then, identify the boundaries and apply BVA. Take about 10 minutes to complete this before checking your work against the suggested solution below.
Click here to see a suggested solution
Here is a possible set of test cases. Your list may vary slightly, but it should cover similar categories and boundaries.
| Test Case ID | Input Value | Technique | Expected Outcome |
|---|---|---|---|
| TC-01 | 9 | BVA | Error |
| TC-02 | 10 | BVA | Success |
| TC-03 | 11 | BVA | Success |
| TC-04 | 50 | EP | Success |
| TC-05 | 89 | BVA | Success |
| TC-06 | 90 | BVA | Success |
| TC-07 | 91 | BVA | Error |
| TC-08 | -5 | EP | Error |
| TC-09 | 150 | EP | Error |
| TC-10 | "abc" | EP (type) | Error |
| TC-11 | 15.5 | EP (type) | Error |
| TC-12 | null | EP (type) | Error |
Conclusion
In this lesson, you've acquired two of the most fundamental and practical test design techniques in the industry. You are no longer just guessing which inputs to test; you are now able to systematically analyze a feature's requirements and derive a concise yet powerful set of test cases.
Key Takeaways:
- Exhaustive testing is impossible. Test design techniques are used to select a small, optimal set of test cases.
- Equivalence Partitioning divides inputs into groups that are expected to behave similarly, allowing you to test one representative from each group.
- Boundary Value Analysis complements this by focusing on the high-risk values at the edges of these partitions, where bugs are most likely to occur.
- These techniques are used together to create a test suite that is both efficient and effective, maximizing bug detection while minimizing redundant tests.
You now know how to choose the right values for your tests. In our next lesson, "Write unit tests for Java methods using JUnit and for React components using React Testing Library," we will take the final step and implement these test cases in code. You will see how the values you just designed become the concrete inputs in your automated JUnit and React tests.