Question bank › GCSE › GCSE Computer Science › Programming

Testing, test data & error types

10 questions45 marksabout 55 min

Answer on paper first, then reveal the mark scheme one mark at a time.

1Grade 4–54 marks

(a) Explain the difference between a syntax error and a logic error. [2]

(b) For each line below, state whether it contains a syntax error or a logic error. [2]

(i) IF score > 50 THN

(ii) A program meant to find the mean of 5 numbers uses mean ← total / 4

2Grade 4–54 marks

A program accepts the age of a student at a secondary school. Valid ages are 11 to 18 inclusive.

(a) Give an example of each type of test data and state the expected result. [3]

(i) normal (ii) boundary (iii) erroneous

(b) Explain why a programmer tests a program with erroneous data. [1]

3Grade 6–76 marks

A subroutine should return True if a test mark is valid. Valid marks are from 0 to 100 inclusive.

SUBROUTINE validMark(mark)
   IF mark > 0 AND mark < 100 THEN
      RETURN True
   ELSE
      RETURN False
   ENDIF
ENDSUBROUTINE

(a) The subroutine is tested with the marks 50, 0, 100 and 101. For each test, state the expected result and the actual result. [2]

(b) State the type of error in the subroutine. [1]

(c) Rewrite the condition in the IF statement so that the subroutine works correctly. [1]

(d) Explain why testing with only normal data would not have found this error. [1]

(e) The program reads mark using STRING_TO_INT(USERINPUT). Explain why the program could still fail if a user types ten. [1]

Stuck on Testing, test data & error types?

Get it sorted in a free 30-minute session

We work through your weakest questions on this topic on Zoom. I reply the same day.

4Grade 1–33 marks

A website asks new users to choose a password. The password must be between 8 and 16 characters long (inclusive).

(a) State the purpose of testing a program. [1]

(b) State one example of boundary test data for the password length. [1]

(c) State one example of erroneous test data for the password length. [1]

5Grade 4–54 marks

A quiz program asks the user how many questions they want to answer. The number must be from 5 to 20 inclusive.

A programmer starts to write a test plan for this input.

TestTest dataType of test dataExpected result
112NormalAccepted
220(a) ……………Accepted
34Boundary(b) ……………
4(c) ……………ErroneousRejected with error message

(a) State the type of test data for test 2. [1]

(b) State the expected result for test 3. [1]

(c) Suggest suitable test data for test 4. [1]

(d) The programmer says test 1 is enough on its own because "12 is a typical value, so if that works the program works". Explain why the programmer is wrong. [1]

6Grade 4–54 marks

The program below should add up the prices of three items and output the total. Line numbers are shown for reference only.

1  total ← 0
2  FOR i ← 1 TO 3
3     price ← STRING_TO_REAL(USERINPUT)
4     total ← total - price
5  OUTPUT 'Total is ' + REAL_TO_STRING(total)

The program contains one syntax error and one logic error.

(a) State the line number where the syntax error occurs and describe how to correct it. [2]

(b) State the line number where the logic error occurs and describe how to correct it. [2]

7Grade 6–75 marks

A subroutine should return the sum of all the whole numbers from 1 to n inclusive. For example, when n is 4 it should return 1 + 2 + 3 + 4 = 10.

SUBROUTINE sumTo(n)
   total ← 0
   FOR i ← 1 TO n - 1
      total ← total + i
   ENDFOR
   RETURN total
ENDSUBROUTINE

(a) Complete the table to show the expected and actual results of testing the subroutine. [2]

Test data (n)Expected resultActual result
4
10

(b) State the type of error in the subroutine. [1]

(c) Describe how to correct the error. [1]

(d) A programmer suggests also testing the subroutine with n = 1. State the type of test data this is and give the expected result. [1]

8Grade 6–74 marks

An online shop gives a discount based on the number of items in an order:

  • 1 to 9 items: no discount
  • 10 to 49 items: 10% discount
  • 50 or more items: 20% discount

A subroutine getDiscount(items) returns the discount percentage. A student tests it using only the values 5, 30 and 100 and all three tests pass.

(a) Explain why these three tests are not enough to show that the subroutine works correctly. [2]

(b) Give two further pieces of test data the student should use, and the expected result for each. [2]

9Grade 8–96 marks

A subroutine letterGrade(score) should return a grade using these rules:

  • 70 or above: "A"
  • 60 to 69: "B"
  • 50 to 59: "C"
  • below 50: "F"
SUBROUTINE letterGrade(score)
   IF score ≥ 70 THEN
      RETURN "A"
   ELSE IF score > 60 THEN
      RETURN "B"
   ELSE IF score ≥ 50 THEN
      RETURN "C"
   ELSE
      RETURN "F"
   ENDIF
ENDSUBROUTINE

The subroutine was tested with the results shown.

Test dataExpectedActualPass / Fail
85AAPass
70AAPass
69BBPass
60BCFail
59CCPass
50CCPass

(a) Using the test results, explain how a programmer can tell which line of the subroutine contains the error. [2]

(b) Rewrite the faulty line so that the subroutine works correctly. [1]

(c) State why the test with 85 did not reveal this error. [1]

(d) The test plan has no test for the lowest band. Give one piece of boundary test data for the "F" grade and its expected result. [1]

(e) State the type of error in the original subroutine. [1]

10Grade 8–95 marks

A restaurant booking program reads the number of guests in a booking using the line

guests ← STRING_TO_INT(USERINPUT)

and then checks that guests is between 1 and 8 inclusive. The developer runs a test plan containing the values 1, 4, 8, 0 and 9. Every test passes, and the developer says: "The program has no errors."

(a) Explain why passing every test in this plan does not prove the program has no errors. [2]

(b) Describe one piece of erroneous test data that is not a whole number, and explain what could happen when the program runs with it. [2]

(c) The developer's test plan did not find any syntax errors. Explain why this is not surprising. [1]

Stuck on this topic?

Book a free 30-minute session on WhatsApp and we'll find exactly which step is costing you the marks. Or build a timed paper on it.

Free 30-minute session