AS · Practice questions · Types of error and testing methods

Expose every fault.

Six original Cambridge-style questions on types of error and methods of testing, with mark-scheme style solutions.

Original questions All questions on this page are original work, written in the Cambridge AS & A Level style. They are not from past papers. They test the same concepts and skills the syllabus rewards.
Keep these straight

When does it show?

01
Explain
[3 marks]

Describe a syntax error, a logic error and a run-time error.

  • Syntax error: code that breaks the grammar rules of the language, so it cannot be translated. ✓
  • Logic error: an error in the algorithm; the program runs but produces an incorrect result. ✓
  • Run-time error: an error that occurs while the program is running, causing it to crash or hang (e.g. division by zero). ✓
02
Analysis
[6 marks]

The function should return the sum of the integers from 1 to N.

FUNCTION SumTo(N : INTEGER) RETURNS INTEGER
    DECLARE Count, Sum : INTEGER
    Sum ← 1
    Count ← 1
    WHILE Count < N
        Sum ← Sum + Count
        Count ← Count + 1
    ENDWHILE
    RETURN Sum
ENDFUNCTION

The function contains two errors. Identify each error, state its type and write the correction.

  • Sum ← 1 should be Sum ← 0 (logic error). ✓
  • The 1 is counted twice: with N = 3 the code returns 1 + 1 + 2 = 4. ✓
  • WHILE Count < N should be WHILE Count <= N (logic error). ✓
  • Otherwise N itself is never added. ✓
  • Corrected: Sum ← 0 and WHILE Count <= N. ✓
  • Check: N = 3 gives 0 + 1 + 2 + 3 = 6. ✓
03
Recall
[2 marks]

Give two ways a programmer can avoid making errors when writing code.

  • Any two from: design first with structure charts / pseudocode; use small modules; meaningful identifiers, comments, indentation; use tested library routines; use constants; validate input; use IDE features such as syntax highlighting and auto-complete. ✓
04
Explain
[4 marks]

Explain the difference between white-box testing and black-box testing.

  • White-box: the tester can see / uses knowledge of the code. ✓
  • Test data is chosen to test every path / branch through the code. ✓
  • Black-box: the code is not looked at; testing is based on the specification. ✓
  • The actual outputs for given inputs are compared with the expected outputs. ✓
05
Explain
[3 marks]

A team is developing a program top-down. The main module is written but the modules it calls are not. Explain how stub testing lets the main module be tested now.

  • Each missing module is replaced by a stub: a dummy module with the same name and parameters. ✓
  • The stub outputs a message to show it was called and / or returns a fixed value. ✓
  • So the main module's logic and calls (and parameter passing) can be tested before the real modules exist. ✓
06
Apply
[3 marks]

Describe alpha testing, beta testing and acceptance testing, saying who carries out each.

  • Alpha: testing of a nearly complete program in-house by the developer's own staff / testers. ✓
  • Beta: a nearly finished version is given to a limited number of real users outside the company, who report faults. ✓
  • Acceptance: the client / end user tests the finished program against the requirements before accepting it. ✓

Mark this once you have attempted all six and checked your working. It records a Practiced badge on the topic and adds a one-time bonus. Revealing the solutions alone does not count.