TopMyGrade

GCSE/Computer Science/OCR

2.3.2Testing: iterative vs final testing, types of test data (normal, boundary, invalid/erroneous) and refining solutions

Notes

Testing programs

Testing is the process of running a program with carefully chosen data to verify it works correctly and find errors. OCR J277 Paper 2 tests three types of test data and two approaches to testing — you must be able to choose and justify test data for a given scenario.

Why is testing necessary?

  • Programs must work correctly for all valid inputs and handle invalid inputs gracefully.
  • Errors (bugs) must be found and fixed before software is deployed.
  • Untested software in safety-critical systems (aircraft, medical devices, banking) can cause injury or financial loss.
  • Testing cannot prove a program is completely error-free — it can only demonstrate that tested cases work.

Two approaches to testing

Iterative testing

  • Testing is performed throughout development, after each module or feature is completed.
  • Errors are found and fixed early — when they are cheapest to correct.
  • Each iteration tests new code AND regression-tests previous code to ensure changes didn't break anything.
  • Advantage: bugs found early; easier to isolate which change caused a bug; continuous feedback.

Final (terminal) testing

  • Testing is performed after the entire program is complete.
  • The finished product is tested against requirements.
  • Advantage: tests the system as a whole (integration testing).
  • Disadvantage: bugs found late are expensive to fix; may require redesign; deadlines may limit thorough testing.

Three types of test data

1. Normal (valid) data

  • Data that is within the expected valid range.
  • The program should accept and process this data correctly.
  • Example: for an age input (1–120): test data = 25, 50, 100.

2. Boundary data

  • Data at the extreme edges of the valid range.
  • Must test the boundary itself AND just outside it (both sides).
  • The program should accept data at the boundary but reject data just beyond it.
  • Example: for age 1–120:
    • Boundary accepted: 1, 120.
    • Boundary rejected: 0, 121.

Why boundary data? Programs often have "off-by-one" errors (e.g. > 120 instead of >= 120). Boundary data specifically catches these.

3. Invalid / erroneous data

  • Data that is outside the valid range, wrong type, or in the wrong format.
  • The program should reject this data (not crash, not accept silently).
  • Example for age 1–120:
    • Out of range: -5, 0, 999, 200.
    • Wrong type: "hello", "abc".
    • Empty input: "" (blank).

Summary table

TypeExample (age 1–120)Expected outcome
Normal25, 70Accepted, processed
Boundary1, 120, 0, 1211 and 120 accepted; 0 and 121 rejected
Invalid/erroneous-5, 999, "hello"Rejected with error message

Trace tables

A trace table is used to manually trace the execution of an algorithm step by step, tracking variable values at each stage.

  • Used to verify algorithm logic before coding.
  • Used to find where a program produces incorrect output.
StepitotalOutput
Start-0
i=005
i=1112
i=221818

Refining solutions

After testing, bugs are fixed (debugging), and the program may need refinement to:

  • Handle edge cases not originally considered.
  • Improve error messages.
  • Optimise performance.
  • Improve code readability.

Common OCR exam mistakes

  1. Confusing boundary with invalid data — boundary data IS valid (at the edge); invalid data is OUTSIDE the range.
  2. Only giving one boundary value — always test BOTH edges of the range AND the values just outside.
  3. Saying "testing proves the program is correct" — testing can only show the program works for the cases tested; it cannot prove correctness for all possible inputs.
  4. Confusing iterative testing with iteration (loops) — iterative testing means testing throughout development; it has nothing to do with programming loops.

AI-generated · claude-opus-4-7 · v3-ocr-computer-science

Practice questions

Try each before peeking at the worked solution.

  1. Question 15 marks

    Types of test data

    A program accepts a percentage score entered by a student. Valid scores are integers from 0 to 100.

    Complete the test table by identifying the type and expected outcome for each test value:

    Test valueTypeExpected outcome
    55??
    0??
    101??
    -10??
    100??

    [5 marks]

    Ask AI about this

    AI-generated · claude-opus-4-7 · v3-ocr-computer-science

  2. Question 22 marks

    Iterative vs final testing

    Explain one advantage of iterative testing over final (terminal) testing. [2 marks]

    Ask AI about this

    AI-generated · claude-opus-4-7 · v3-ocr-computer-science

  3. Question 34 marks

    Choosing test data

    A student writes a program that asks a user to enter a PIN which must be exactly 4 digits long. Suggest two appropriate test values and state the type and expected outcome for each. [4 marks]

    Ask AI about this

    AI-generated · claude-opus-4-7 · v3-ocr-computer-science

Flashcards

2.3.2 — Testing: iterative vs final testing, types of test data (normal, boundary, invalid/erroneous) and refining solutions

7-card SR deck for OCR Computer Science (J277) topic 2.3.2

7 cards · spaced repetition (SM-2)