Skip to main content
AP CSP course

C08 · Topic 1.4 · 40 minutes · CRD-2.I, CRD-2.J

Boundary cases and test evidence

By the end you can:

  • Choose a test that distinguishes two versions.
  • Include empty, typical and boundary cases.
  • Explain what passing tests do and do not prove.

Before this lesson: topics 3.1, 3.6.

Logic error
Code runs but its behaviour does not meet the intended rule.
Test case
A specified input and expected output or behaviour used to check a requirement.

Understand

A distinguishing test makes candidate versions produce different results. If both versions give the same output, that test cannot isolate their difference. Boundaries are especially valuable when a requirement uses “at least”, “at most” or an inclusive interval.

Use a small set with explicit purposes: a typical case, a boundary, a case with no qualifying data, repeated qualifying data and an empty collection where allowed. Passing this set is useful evidence, not proof of correctness for every input. Re-run relevant earlier tests after a repair to catch regressions.

Worked example

Correct≥counter versus a faulty>counter, and a reset-inside counter.

  1. [5],minimum 5 separates≥from>, but does not reveal reset-inside if only one item qualifies.
  2. [6,6],minimum 5 exposes reset-inside:2 versus 1.
  3. []checks that initialization/return work even when the loop body never runs.

Explore each concept

Choose a concept, change its inputs and follow the explanation. Each example models the stated rule or scenario; completing it is practice rather than evidence of mastery.

  • Error classification
  • Expected versus observed output
  • Distinguishing tests and regression
Open this example on its own

Change it · step through · explain

Change an input, predict what will happen, then advance one step. Read why the state changes, reset and experiment. This fixed teaching model does not save progress or award XP.

Ready · Make a prediction

Ready to explore: Locate syntax, execution and logic errors
  1. FaultlogicWaiting
  2. Boundary test value (0–100)5Waiting

Ready to explore: Locate syntax, execution and logic errors

Why: Change an input, predict the first effect, then advance one step.

Try this: Change one input or choose another listed case. Predict the effect, reset and compare the states and governing rule.

Step through and experiment

Change it · step through · explain

Change an input, predict what will happen, then advance one step. Read why the state changes, reset and experiment. This fixed teaching model does not save progress or award XP.

Ready · Make a prediction

Ready to experiment
  1. Input 15,5,1Waiting
  2. Input 25Waiting
  3. Input 3boundaryWaiting

Ready to experiment

Why: Predict the first change, then advance one step.

Try this: Try repeated boundary values, no matches and an empty list.

Check a misconception

Claim: One successful typical input proves the repair is complete.

Different defect types need different distinguishing cases and a stated domain.

Guided practice

Give a boundary test for an inclusive allowed age 12…18 rule implemented with strict endpoints.

Work with a partner. Make a prediction, compare your reasoning, then identify the rule that supports your answer.

Independent transfer

Design a regression suite for a repaired threshold counter and justify every test.

Exit check

How can two algorithms agree on a test yet not be equivalent?

Write your reasoning before comparing with a classmate. If your teacher assigned this task, submit it through My classes to save your work and receive feedback.

Check yourself

  1. Question 1 of 2Which input best exposes>instead of≥at threshold 70?

    Select one answer.

  2. Question 2 of 2Which statement about a test suite is justified?

    Select one answer.

Your practice so far

Check an answer to see its rationale.

Teacher guidance and scoring