Equivalence classes and boundary values

Choosing test data without testing everything: splitting the inputs into valid and invalid equivalence classes, then aiming at the values at each class's boundaries, just before, on and just after.

  • 23 cards
  • 4 topics
  • Free

The outline, topic by topic

Each topic is weighted the way the exam weighs it.

  1. Concepts
  2. Questions
  3. Sort and link
  4. On the timeline

A few cards from the deck

  • Equivalence class: what is it?

    Show the answer

    A set of inputs that the program must handle in the same way, so that a single one of them is enough to stand for it in the tests.

    Testing 40 and 41 when the class is "between 26 and 60" teaches nothing more: if one passes, so does the other, unless the code has a splitting flaw.

  • Delivery is free for a basket strictly above €50, in whole euros. Which pair of values straddles the boundary?

    • €50 (charged) and €51 (free)
    • €49 (charged) and €50 (free)
    • €50 (free) and €51 (free)
    • €0 (charged) and €100 (free)
    Show the answer

    €50 (charged) and €51 (free)

    "Strictly above" excludes 50: the last charged value is 50 and the first free one is 51. Thinking 50 is free means reading >= instead of >; 0 and 100 are far from the boundary and let that mistake through.

  • For each boundary, one generally tests the value …, the boundary itself and the value ….

    Show the answer

    For each boundary, one generally tests the value just before, the boundary itself and the value just after.

    These three points cover the < for <= mistakes, > for >= and off-by-one shifts.

  • Invalid class: what is it?

    Show the answer

    A set of inputs that the program must reject or flag, because they fall outside what it accepts.

    For a month from 1 to 12, "too small" (0 and below), "too large" (13 and above) and "not a number" are three distinct invalid classes, each to be tested.

  • This function must return true from age 18. Which test case fails with this code?

    ```java
    static boolean estMajeur(int age) {
    return age > 18;
    }
    `

    • age = 17, expected result: false
    • age = 18, expected result: true
    • age = 30, expected result: true
    • age = 19, expected result: true
    Show the answer

    age = 18, expected result: true

    With > 18, 18 is rejected: only the test on the exact boundary sees it. 17, 19 and 30 give the right result with > as with >=.