Software testing techniques help ensure software quality and reliability, by helping us select test cases intelligently from the collection of test cases, such that all test scenarios are covered.
Equivalence Partitioning and Boundary Value Analysis are two testing techniques that help testers select a subset of test cases that covers all important test scenarios, even under time and budget constraints. By testing all the equivalence classes and boundary values, testers can reduce the risk of releasing software with defects.
Test cases are specific input variable values that are used to test a software program and are derived from Boundary Value Analysis and Equivalence Partitioning.
Equivalence Partitioning
Definition and Importance
Equivalence partitioning, also known as Equivalence Class Partitioning is a black box testing technique that divides input data into equivalence classes, which are groups of data that are expected to behave the same. This technique can be applied to all levels of, including unit, integration, and system testing. It is a powerful technique that helps ensure complete and efficient testing of complex systems with many input parameters.
How it Works
Equivalence Partitioning: A Technique for Reducing Test Cases
To use equivalence partitioning, testers first identify the input domain. They then divide the input data units into equivalent partitions based on common characteristics, such as data type, range, valid values and invalid partitions. Once the equivalence data partitions have been defined, testers can select representative test cases from each class. This approach reduces the number of test cases needed to cover all possible input values, which saves testing time and resources.
Examples
Example 1:
Consider a software system that takes a user’s age as input. We could use equivalence partitioning to divide the possible inputs into the following classes:
Negative ages
Ages between 0 and 18
Ages between 19 and 64
Ages over 65
We would then test one or more input data from each class to ensure that the software system behaves as expected.
Example 2:
Using equivalence partitioning to test a function that calculates the area of a triangle, we might divide the input domain into two equivalence classes:
Valid triangle side lengths: All positive real numbers greater than zero.
Invalid triangle side lengths: All negative real numbers, zero, and all combinations of triangle side lengths that do not satisfy the triangle inequality.
Benefits of using Equivalence Partitioning:
Reduced testing time and effort: By selecting a representative test case from each equivalence class, testers can reduce the number of test cases needed to cover all possible input values. This saves time and resources.
Improved test coverage: Equivalence partitioning helps to ensure that all possible input values are tested, including valid, invalid, and boundary values. This improves the overall test coverage and reduces the risk of shipping software with defects.
Simplified testing: Equivalence partitioning simplifies the testing process by grouping input data values into different equivalence data classes. This makes it easier to identify and test cases.
Boundary Value Analysis
Definition and Importance
Boundary value (BVA) is another black box testing technique that focuses on testing the input boundaries and output domains. This technique is important because it helps to identify and fix defects that may occur at the edges of these domains.
How it Works
Boundary Value Analysis involves testing the following values:
Valid boundary values of the input domain: This includes the minimum and maximum valid values.
Invalid boundary values just outside the boundaries of the input domain: This includes values that are slightly too small or too large to be.
Special values: This includes boundary values such as empty strings, null values, and invalid characters.
Examples
Let’s consider testing a web form that requires a user to enter a date of birth. The tester would enter valid dates of birth at the boundaries of the input domain e.g., 01/01/1900 and 12/31/2023. They would also enter invalid dates of birth just outside the boundaries of the input domain e.g., 12/31/1899 and 01/01/2024.
An online coffee shop needs to make and deliver coffee orders from 1 to 50 cups. To use boundary value testing, we analyze the extreme ends of the input domain. The maximum value is 50 and the minimum value is 1. The invalid values in this test case will be 0 and 51.
Benefits of using boundary value analysis technique:
A Comprehensive approach to testing: Boundary value analysis covers both and invalid input values. This helps to ensure that the software is tested for all possible input scenarios.
Systematic and logical approach to testing: Boundary value analysis can be used to generate test cases for all of the equivalence classes and values of the input domain. This helps to ensure that the testing is comprehensive and systematic.
Efficient approach to testing. Boundary analysis can help to reduce the number of test cases that need to be executed. This is because boundary value analysis focuses on testing the most critical input values.
Cost-effective approach to testing. Boundary value analysis can help to reduce the cost of testing by reducing the number of test cases that need to be executed and by finding defects early in the development process.
Equivalence Partitioning vs Boundary Value Analysis
Equivalence | Boundary Value Analysis
|
Equivalence Partitioning groups input | Boundary Value Analysis tests input values
|
Equivalence Partitioning is typically used to test the
| Boundary Value Analysis is typically used to test the robustness and reliability of a |
When to Use Which Technique
The best technique to use for a given testing scenario depends on the specific requirements of the system. If the goal is to test the functionality of the system, then is a good choice. If the goal is to test the robustness and reliability of the system, then Boundary Value Analysis is a good choice.
Here are some general guidelines
Equivalence partitioning is best for testing large and complex input domains.
Boundary value analysis is best for testing small and simple input domains, or systems that need to handle unexpected input values.
Use both techniques for the most comprehensive test coverage.
Equivalence Class Partitioning and Boundary Value Analysis for Web Applications
Web applications are complex with many moving parts. To test them effectively, it’s important to identify all the different types of input they can receive. Once you’ve identified the input types, you can generate equivalence classes and boundary values.
Here is an example of how to use equivalence class partitioning and boundary value analysis to test a web application login form:
Equivalence Classes
Valid usernames: Alphabetical characters, minimum length of 6 characters and maximum length of 10 characters.
Invalid usernames: Special characters, usernames shorter than 6 characters and longer than 10 characters.
Valid passwords: Alphabetical characters, numbers, and special characters, with a minimum length of 8 characters.
Invalid passwords: Passwords shorter than 8 characters, passwords without special characters.
Boundary Values
Minimum username length: 6 characters
Maximum username length: 10 characters
Minimum password length: 8 characters
Maximum password length: 20 characters
Test Cases
Valid username: “myusername”
Invalid username: “myusername!”
Valid password: “MyPassword!”
Invalid password: “mypass”
By using equivalence class partitioning and boundary value analysis, you can generate a comprehensive set of test cases that will help you to identify and fix any defects in your web application.
Equivalence Partitioning and Boundary Value Analysis for Mobile Applications
Mobile applications are similar to web applications in that they can receive a variety of different types of input. However, mobile applications also have additional components, such as the device’s sensors and hardware.
Here is an example of how to use equivalence class partitioning and boundary value analysis to test a mobile application that uses the device’s accelerometer sensor:
Equivalence Classes
Valid accelerometer readings: Accelerometer readings are within the normal range.
Invalid accelerometer readings: Accelerometer readings outside of the normal range.
Boundary Values
Minimum accelerometer reading: The minimum value that the accelerometer sensor can measure.
Maximum accelerometer reading: The maximum value that the accelerometer sensor can measure.
Test Cases
Valid accelerometer reading: (0.1, 2, 0.3)
Invalid accelerometer reading: (100, 200, 300)
Conclusion
There are two testing techniques – Equivalence Partitioning and Boundary Value Analysis.
Equivalence partitioning is best for testing large and complex input domains.
Equivalence partitioning begins by dividing a set of test conditions into equivalence classes.
Boundary value analysis is best for testing small and simple input domains, or systems that need to handle unexpected input values.
Boundary value analysis involves testing the input values at the edges of equivalence partitions.
Use both techniques for the most comprehensive test coverage.
Frequently Asked Questions
Equivalence partitioning is a valuable testing technique that can be used to improve the quality and reliability of software. It is a powerful tool for ensuring thorough and efficient testing, especially for complex systems with a large number of input parameters.
Boundary value analysis is a valuable software testing technique because it is simple to implement, comprehensive in scope, systematic in approach, efficient in terms of time and resources, and cost-effective.
Equivalence partitioning does not automatically cover boundary value analysis.
Equivalence partitioning divides the input domain of a software program into equivalence classes, which are groups of input values that are expected to behave the same.
Boundary value analysis focuses on testing the input values at the boundaries of the input domain, such as the minimum and maximum values.
Example: Using boundary value analysis, we would test the following input values:
- Minimum triangle side length: 0
- Maximum triangle side length: Infinity