Equivalence Partitioning And BVA | Efficient Test Case Design
What is Black Box Testing?
It is also known as behavioral, opaque-box, closed-box, specification-based or eye-to-eye testing.
Black Box testing is a type of Dynamic Testing, and it is defined as a testing technique in which functionality of the Application Under Test (AUT) is tested without looking at the internal code structure, implementation details and knowledge of internal paths of the software.
It’s one of the most powerful method of Testing because the tester doesn’t need to have deep knowledge about the product itself. It’s also the most well used method of testing, and occur throughout the development cycle and Testing Life Cycle i.e in Unit, Integration, System, Acceptance, and Regression Testing stages.
What Are the Techniques You Need To Learn?
When it comes to Black Box Testing, it usually involves 3 techniques to master.
A) Equivalence Class Partitioning:
Equivalence Class Partitioning (or Equivalence Partitioning, or EP for short) is an all-around specification based black-box technique. It is extremely easy to understand, very commonly use and approach in such simple logic that a majority of tester apply or figure it out just by reading specification alone.
In this method, the input domain data is divided into different equivalence data partitions (or classes). Then, we test only one condition in each of those partition. This method is typically used to reduce the total number of test cases to a finite set of testable test cases, still covering maximum requirements. “Maximum requirements” here is emphasized, because certainly it won’t be able to cover all the requirements. This coverage risk can be reduced when this technique is use alongside with Boundary Value Analysis technique, which we will cover later.
For example, to test an age restriction system for opening an account at a bank. In specification, the user is required to be over 18 to be able to open their own account. To test this system, first we must identify the range of ages (or partitions) that can and cannot create account as below:
Valid partition: age>= 18. Input value: 19
Invalid partition: 0<=age<18. Input value: 5
Please note that we have identified 2 partitions, not just the one
mentioned in the specification. As a tester, it is important to test every possibilities, especially the ones that is not specified yet. In our experience, that’s where most of the bugs are found, as missing information in specification can become developer’s mistake, then later translate in to defect in the system.
However, all the possibilities should still came from the realm of reality: as in this case the age must not be smaller than 0. If a system allows input negative value into age, the test should not be connected with “the user is required to be over 18” requirement, but it should be for an logical validation error such as “Age cannot be negative”.
After we identify the partitions, we only have to choose 1 value from each partition and test those values. In this case we chose the age value of 19 for the valid partition, and 5 for the invalid partition. One might wonder if we have missed some values: There is 19 numbers between 0 and 18 in the invalid partition, and even more number from the valid partition, and we only test 1 in each of them?
It is an understandable concern, but this is how Equivalent Class Partitioning works: To cover every partitions with the lowest number of test case possible. If you want to not only cover every partitions but also check their range, you will want to use the next technique.
B) BVA or Boundary Value Analysis:
Boundary Value Analysis is Black box testing technique that focus not on the partitions, but the boundaries between them. In many case, this is where many bugs would occurs. Bugs found by this technique are called boundary defects.
To use this technique, first we also need to identify all the partitions (just like with Equivalence Class Partitioning).After that, we pick the maximum value and the minimum value possible of each partitions (Valid and
Invalid) to test.
Consider the age restriction system described, with 2 partitions (1 valid and 1 invalid), using this technique, we choose our input value as below:
Valid partition: age>= 18. Input value: 18
Invalid partition: 0<=age<18. Input value:17
These input values signify the boundary between the partitions, also the range of each partitions. Please note that there are partitions that would have less values picked from another (Namely the Valid partition: age>= 18. Input value: 18). This is called an Open Boundary.
C) Using the 2 techniques together:
Equivalence partitioning and Boundary value analysis (BVA) are
closely related and can be used together at all levels of testing. Listing out
partitions and boundaries when designing test case, and we can test many partitions and boundaries with fewest data possible.
For example, for an Employee ID system in an ERP (Enterprise Resource Planning) package has 3-digit number from 100 to 700, we can identify the partitions and boundaries as below:
(1) Digits: With characters from 0 to 9 is the valid partitions
(with boundaries of each digits are 0 and 9) and non-digits for invalid partition.
(2) Number of digits: 3 , so 2 and 4 digits will be the invalid boundaries)
(3) Range of the ID: 100 to 700 is valid boundaries values, 99 and 701 is the invalid boundaries values.
(4) IDs that are taken would be the invalid partition, and those are not is in the valid partition.
(5) If the IDs rise sequentially and automatically, the highest IDs could also be used as boundary values.
With the partitions and boundaries listed out, we can identify some data that can help us test multiple partitions and boundaries at the same time. For example, ID 390 can test valid partitions of (1) and (2) at the same times. Plus, ID 390 can test all the valid boundary values of (1) because it have 0 and 9 in it. Thinking like this will reduce the amount of test cases significantly, and thus reduce the amount of test needed to be executed.
However, one important note is while multiple valid partitions or boundaries can be tested at the same time, sometime multiple Invalid partitions and Invalid boundaries should not be tested in the same test case. The reason is some system might stop its processing when they encounter the first problem, and only appear the error for that specific problem only. In case of the example above: we should not test ID 1000 for (3) and (4) at the same time because the system might stop processing from (3) and only appear error of (3) without checking (4). If the system is not stopping at its first problem, or multiple error message can be appeared at the same time, then you can proceed to test multiple of them without problem.
This blog is written by our software test engineer TONY.
For any inquiries or consultation request, please reach out through contact form.