Skip to content

Februar 5, 2025

Equivalence class partioning and boundary value analysis

Basics of the equivalence class method

The equivalence class method is a test case derivation technique that aims to divide the input data of a system into groups or classes in which the values can be considered equivalent. Equivalent means that each value within a class should behave identically in the test case behavior, whereby it is sufficient to test with only one representative of each class.

Example of an equivalence class division

Assume a form accepts numbers between 1 and 100 as valid input:

Input valuesEquivalence classValidity
-10, 0invalidNo
1 – 100validYes
101, 150invalidNein

Combination with the boundary value analysis

Boundary value analysis is a complementary technique to the equivalence class method that focuses on testing the edges of the equivalence classes. As errors often occur at the limits of a valid value range, these values are particularly critical for tests.

Example of the boundary value analysis

For the above numerical range (1 – 100), the relevant limit values could be defined as follows:

Input valuesClassificationExpected result
0Lower boundary -1Defect
1Lower boundarySuccess
100Upper boundarySuccess
101Upper boundary +1Defect

The combination of both methods ensures a more precise test coverage by testing representative values from each equivalence class as well as critical boundary values.

Application in Data Driven Testing

Data Driven Testing is based on the idea of executing a large number of test cases with different input values. The equivalence class method helps to optimize the amount of test data.

Advantages of combining DDT with equivalence classes and boundary value analysis

  1. Reduction of redundant tests: Instead of testing all possible inputs, only representative values from each equivalence class and critical boundary are selected.
  2. Reduction of redundant tests: Instead of testing all possible inputs, only representative values from each equivalence class and critical boundary are selected.
  3. Higher test coverage with fewer test cases: Critical test cases are covered without performing unnecessary tests.
  4. Higher test coverage with fewer test cases: Critical test cases are covered without performing unnecessary tests.
  5. Higher test coverage with fewer test cases: Critical test cases are covered without performing unnecessary tests.

Visualization of equivalence classes and boundray value analysis

A diagram can illustrate the classification of the equivalence classes and the relevant boundary values:

  • X-axis: Input values
  • Y-axis: Validity

Test data matrix for data-driven testing with limit value analysis

Test caseInput valuesExpected result
TC1-10Defect
TC20Defect
TC31Success
TC450Success
TC5100Success
TC6101Defect

Example 1: Age check for the registration of an online platform

Suppose an online platform only allows users between the ages of 18 and 65 to register. The software validates the age based on the number entered by the user.

Equivalence class analysis

Input valuesEquivalence classValidity
0 – 17InvalidNo
18 – 65ValidYes
66 und höherInvalidNo

Boundary value analysis

Here we specifically test the values at the boundary of the equivalence classes:

Test caseInput valuesExpected result
TC117Defect (too young)
TC218Success (currently valid)
TC330Success (currently valid)
TC465Success (just valid)
TC566Defect (too old)

Explanation of the test strategy

  • By combining the equivalence class method and boundary value analysis, we minimize the test cases while still ensuring maximum defect coverage.
  • Instead of testing all ages between 18 and 65, we choose only representative values.
  • The thresholds 17, 18, 65, 66 are critical as defects in the implementation often occur here.

This example shows how these simple methods help to efficiently test the quality of an application in practice.

The example above shows the simplest partioning into equivalence classes: a class with valid and a class with invalid representatives. The second example combines several data types with several equivalence classes.

Example 2: Flight ticket prices based on age and booking class

A flight booking system calculates the ticket price depending on the age of the passenger and the booking class. The prices and booking conditions are as follows:

  • Children (0-11 years) receive a 50% discount, but may only travel with an adult.
  • Teenagers (12-17 years) pay the full price.
  • Adults (18-64 years) pay the full price.
  • Seniors (65+ years) receive a 20% discount.
  • Normal prices apply in Economy class.
  • In Business Class there is a surcharge of 50% on the base fare.
  • In First Class there is a surcharge of 100% on the base fare.

Equivalence class analysis

Here we divide the possible inputs into equivalence classes for two data types:

Age of the passengerEquivalence classPermitted bookingDiscount/surcharge
0 – 11 JahreKidsOnly with adult-50%
12 – 17 JahreTeenagersYesNo discount
18 – 64 JahreErwachseneYesNo discount
65+ JahreSeniorenYes-20%
Booking classEquivalent classPrice rule
EconomyStandardNormal price
BusinessPremium+50%
First ClassLuxus+100%

Boundary value analysis

Here we specifically test the boundary values between the equivalence classes:

Test CaseInput ValuesExpected result
TC10Defect (child without adult)
TC21Defect (child without adult)
TC311Defect (child without adult)
TC412Success (transition child → teenager)
TC517Success (last teenage stage)
TC618Success (transition teenager → adult)
TC764Success (last adult stage)
TC865Success (transition adult → senior with 20% discount)
TC980Success (Senior with 20% discount)
TC1030Success (50% surcharge)
TC1140Success (100% surcharge)

Explanation of the test strategy

  • Several equivalence classes for age and booking class.
  • Boundary value analysis checks whether the system processes the transition between age groups correctly.
  • Special case: Children must travel with an adult, therefore TC1-TC3 are invalid.
  • Discount and surcharge calculations are checked.

Conclusion

Combining the equivalence class method with boundary analysis is a valuable technique in Data Driven Testing to select test cases and increase test efficiency. While equivalence classes sensibly reduce the amount of test data, boundary value analysis ensures that critical edge cases are not overlooked. This systematic selection of test data can ensure the quality of the software and minimize the testing effort at the same time.