Computer Engineering is coming soon

We're still writing and reviewing the notes for every subject, and we'll open it when every subject is ready. Meanwhile you can practise aptitude, ask Aria about any subject, or see the branches that are ready.

Black-box techniques: boundary values and equivalence partitioning

Black‑box testing uses Equivalence Partitioning and Boundary Value Analysis to choose small, effective sets of test inputs from large input domains, reducing test effort while keeping good defect coverage.

Drafted with Aria, reviewed by the AiCanCode.org team · Updated . How we write and check our notes. Spotted an error? Use Give Feedback at the bottom of the page.

Why it matters

Black‑box techniques are used by engineers when they design test cases from the software specification without looking at source code. Equivalence partitioning and boundary value analysis let a tester turn a large or infinite input domain into a small set of representative test inputs that catch many common errors — this saves time in unit, system and acceptance testing and is often required in formal Test Planning and Test Case documents.

Key ideas

Define terms before using them.

  • Black‑box testing: testing based only on requirements and specification; the tester does not use internal code structure. (Use when you want to validate behavior against requirements and when testers are independent of developers.)
  • Input domain: the set of all possible inputs a program or function can accept. (For example, integers 0..100, strings up to 256 characters.)
  • Equivalence partitioning (EP): a technique that divides the input domain into disjoint equivalence classes (also called partitions) such that all values in a class are expected to be treated the same way by the program. A single representative from each class can be used as a test input. Exact definition: "An equivalence partition is a subset of the input domain for which the software exhibits the same observable behavior for any input value in that subset, according to the specification." Assumption: the specification is precise enough to decide observable behavior for each input. EP can also be applied to output domains or to partition expected behaviors (e.g., different messages or state transitions) when deriving tests.
  • Valid equivalence class: an equivalence class that contains inputs allowed by the specification.
  • Invalid equivalence class: an equivalence class that contains inputs that should be rejected or lead to error handling.
  • Boundary value analysis (BVA): a technique that selects test inputs at, just below and just above the boundaries of equivalence classes because many defects occur at the edges of allowed ranges. Exact practical rule (stated as used in exams): for a numeric discrete interval [a, b], test values should include a, a+1, b-1, b and also a-1 and b+1 if invalid-value testing is required.

Step‑by‑step method to derive tests from a specification (what universities expect):

  1. Read the specification and list the input fields with their valid ranges and types (discrete/continuous, enumerated, string length, format). Define the input domain for each field.
  2. For each input field, identify equivalence classes. There are usually two kinds:
    • Valid classes (each distinct expected behavior or category inside allowed range)
    • Invalid classes (values outside allowed range, wrong type, format errors)
  3. For each equivalence class pick one representative value to form EP test cases.
  4. For BVA, identify numeric or ordered boundaries between adjacent equivalence classes. For each boundary, select values at the boundary and just inside/outside it. For multiple input fields, under the single‑fault assumption vary one field to its boundary values while holding other fields at nominal in‑range values; for robust BVA also include out‑of‑range points (a−1, b+1 where representable) for the varied field.
  5. Combine single‑field test values into multi‑field test cases using a minimal combination strategy (pairwise or all‑pairs if required). When fields interact, you may need additional combined cases.
  6. Write expected output/behavior for each test case from the specification.

Diagrams to draw in an exam answer (describe what to draw and label):

  • Draw a horizontal number line representing the domain of a numeric input. Mark partition boundaries as vertical ticks and label regions (e.g., Invalid1, ValidLow, ValidHigh, Invalid2). On each boundary, mark sample test points: just left, exactly at, just right of the tick and label them with values (e.g., a-1, a, a+1). Add arrows and a legend explaining valid vs invalid.

Assumptions and caveats (explicit):

  • EP assumes the specification correctly groups values by observable behavior. If the implementation treats two values differently, EP may miss defects.
  • BVA assumes most defects are at boundaries, but not all defects are boundary-related (combinational or state issues require other techniques).
  • For continuous domains use a small epsilon (ε) to indicate just‑above/just‑below (write as a+ε, b−ε) and state what ε represents in context. In IEEE‑754 floating‑point implementations, prefer using the next representable values toward/away from the boundary (e.g., via nextafter/ULP) rather than an abstract fixed ε, and state how those values are obtained.

Formulas

(Note: this topic is mainly procedural; the lines below are syntax and canonical point sets you should remember.)

TC format: TC-id | Preconditions | Input(s) | Expected output | Postconditions — the fields to write for each test case.

BVA discrete set for interval [a,b]: {a-1, a, a+1, b-1, b, b+1} — where a-1 and b+1 are used to test invalid values; applies when domain is integers and a-1/b+1 are representable.

BVA continuous set for interval [a,b]: {a, a+ε, b-ε, b} — where ε is a very small positive value consistent with the domain (e.g., smallest representable increment or value defined by spec).

EP representative rule: choose one value r_i ∈ EC_i for each equivalence class EC_i — choose r_i so it is clearly inside the class (not another boundary point unless you intend to test the boundary).

Combination rule (naive worst case): product of numbers of classes per field — worst‑case number of combinations; list this to explain why combination reduction strategies (pairwise, orthogonal arrays) are used.

Equivalence class testing variants (multi‑field):

  • Weak normal EC testing: Cover each valid class of each field at least once using a baseline all‑valid test and then varying one field at a time to exercise its other valid classes (single‑fault assumption).
  • Weak robust EC testing: As weak normal, plus one test per invalid class of each field, varying one field at a time to an invalid representative while others remain valid.
  • Strong normal EC testing: All combinations of valid classes across fields; count = ∏ v_i (v_i = number of valid classes for field i).
  • Strong robust EC testing: All combinations of valid and invalid classes across fields; count = ∏ (v_i + r_i) (r_i = number of invalid classes for field i).

Worked examples

Example 1 — Numeric marks → letter grade (typical exam question)

Specification (explicit): Input: integer marks ∈ Z. Valid marks are 0..100 inclusive. Output: Grade as follows: 90–100 → A, 80–89 → B, 60–79 → C, 40–59 → D, 0–39 → F. Invalid if marks < 0 or marks > 100.

Step 1: identify equivalence classes

  • EC1 (invalid): marks < 0
  • EC2 (valid): 0–39 (F)
  • EC3 (valid): 40–59 (D)
  • EC4 (valid): 60–79 (C)
  • EC5 (valid): 80–89 (B)
  • EC6 (valid): 90–100 (A)
  • EC7 (invalid): marks > 100

Step 2: EP representatives (one per class)

  • EC1: −1 → expect error/invalid
  • EC2: 10 → expect F
  • EC3: 50 → expect D
  • EC4: 70 → expect C
  • EC5: 85 → expect B
  • EC6: 95 → expect A
  • EC7: 101 → expect error/invalid

Step 3: BVA at adjacent boundaries (discrete)

Boundaries between classes: −1/0, 39/40, 59/60, 79/80, 89/90, 100/101.

Using BVA discrete set for each boundary collect typical test points (compile and remove duplicates). Important set (ordered):

  • −1 (invalid), 0, 1
  • 39, 40, 41
  • 59, 60, 61
  • 79, 80, 81
  • 89, 90, 91
  • 100, 101 (invalid)

Compose selected test cases (trim if required by time): pick {−1, 0, 1, 39, 40, 41, 59, 60, 61, 79, 80, 81, 89, 90, 91, 100, 101}. For each compute expected output from table (e.g., 39→F, 40→D, 100→A, 101→invalid).

Example 2 — Password length constraint (short, clear)

Specification: Password accepted if length L where 8 ≤ L ≤ 20; else rejected.

EP classes:

  • EC1 invalid: L < 8
  • EC2 valid: 8 ≤ L ≤ 20
  • EC3 invalid: L > 20

EP representatives: L = 6 (invalid), L = 12 (valid), L = 25 (invalid)

BVA discrete: use {7,8,9,19,20,21} with example strings:

  • 7 chars → expect reject
  • 8 chars → accept
  • 9 chars → accept
  • 19 chars → accept
  • 20 chars → accept
  • 21 chars → reject

Example 3 — Dropdown month (enum) and BVA interpretation

Specification: Numeric month input, integer 1..12 valid; other values invalid.

EP classes: EC1 invalid ≤ 0, EC2 valid 1..12, EC3 invalid ≥ 13.

EP reps: 0 (invalid), 6 (valid), 13 (invalid)

BVA discrete: {0,1,2,11,12,13} — expected results: 0→invalid, 1→valid, 2→valid, 11→valid, 12→valid, 13→invalid.

Note: For enumerated or categorical inputs (e.g., color ∈ {red, green, blue}), EP picks one representative per category; BVA is not applicable unless categories have an ordering.

Common mistakes

  • Forgetting invalid equivalence classes (students often only test valid cases).
  • Combining every EP representative across fields blindly (product explosion) instead of using pairwise or selective combinations when the spec does not require full-cross tests.
  • Misreading closed vs open intervals in the spec (e.g., 0..100 inclusive vs 0..100 exclusive).
  • Using ε without explaining what it means for the data type (e.g., floating point vs time instants).

For your exam

Kinds of questions you will see:

  • Define and explain concepts (definitions of EP, BVA, equivalence class, valid/invalid class).
  • Short notes comparing EP and BVA, and when to use each.
  • Step‑by‑step derivation questions: given a specification produce equivalence classes, boundary values and a test set (often with a small numeric input domain). Expect to draw a number line diagram and label points.
  • Small case studies: combine two fields and ask for minimal test cases; you must explain combination strategy.
  • Practical test‑case writing: produce TC-id, preconditions, inputs and expected outputs.

What a full‑marks answer includes:

  • Clear definitions of terms with bold labels.
  • Explicit statement of assumptions (discrete/continuous, inclusive/exclusive bounds).
  • Correct identification of all equivalence classes (valid and invalid) and labelled diagram when numeric.
  • Appropriate EP representatives and BVA points with justification.
  • Expected results for each selected test case and brief note on combination strategy if multiple fields.

Quick check

  1. What is an equivalence class?
  2. For an integer input 1..10 (inclusive), list BVA discrete test points.
  3. Why must you include invalid classes in EP?

Answers: 1. An equivalence class is a subset of the input domain where the program is expected to behave the same for any value in that subset. 2. {0,1,2,9,10,11}. 3. Because testing only valid classes misses error handling and many faults occur for out‑of‑range or wrong‑type inputs.

Finished this topic? Mark it so your progress, study plan and readiness keep up.

Stuck on something here?