Question bank › GCSE › GCSE Computer Science › Producing robust programs

Testing: test data, test plans, errors

10 questions46 marksabout 55 min

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

1Grade 4–54 marks

A program accepts a whole number from 1 to 100 inclusive.

Give an example of each type of test data for this program.

(a) Normal [1] (b) Boundary [1] (c) Invalid [1] (d) Erroneous [1]

2Grade 4–54 marks

(a) Describe what is meant by iterative testing. [2]

(b) Describe what is meant by final (terminal) testing. [2]

3Grade 6–75 marks

This program should output the average of 5 numbers.

01 total = 0
02 for i = 1 to 5
03     num = int(input("Enter number"))
04     total = total + num
05 next i
06 average = total / 4
07 print("Average is " + str(average)

(a) State what is meant by a syntax error. [1]

(b) Identify the line number of the logic error and write the corrected line. [2]

(c) Identify the line number of the syntax error and write the corrected line. [2]

Stuck on Testing: test data, test plans, errors?

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–34 marks

A cinema booking program asks the user how many tickets they want. The number must be a whole number from 1 to 6 inclusive.

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

(b) The program is tested with the three values below. For each value, state the type of test data it is. [3]

Test valueType of test data
4 
6 
two 
5Grade 4–54 marks

A programmer is working on two programs.

  • Program 1 will not run. The interpreter reports an error on line 2 before any output is produced.
  • Program 2 runs from start to finish without any error message, but the total it displays is wrong.

(a) State the type of error in each program. [2]

(b) Explain why the error in Program 2 is usually harder to find than the error in Program 1. [2]

6Grade 4–55 marks

A smart thermostat app lets the user type in a target temperature. The temperature must be a whole number from 5 to 30 inclusive. Any other input is rejected with an error message.

Complete the test plan below by filling in the five empty cells. [5]

TestTest dataType of test dataExpected outcome
118NormalAccepted
230  
3 InvalidRejected with error message
47.5  
7Grade 6–75 marks

A program converts a test mark into a grade. The rules are:

  • 70 or more: grade A
  • 50 to 69: grade B
  • 30 to 49: grade C
  • below 30: grade F
01 mark = int(input("Enter mark"))
02 if mark >= 70 then
03     grade = "A"
04 elseif mark >= 50 then
05     grade = "B"
06 elseif mark > 30 then
07     grade = "C"
08 else
09     grade = "F"
10 endif
11 print(grade)

The programmer runs the test plan below.

TestTest dataExpected outputActual output
170AA
250BB
330CF
449CC

(a) State which test has failed and the type of error this shows. [2]

(b) Write the corrected version of the line that contains the error. [1]

(c) Explain why boundary test data was needed to find this error. [2]

8Grade 4–54 marks

A board-game program asks how many players there are. The number must be from 2 to 4 inclusive.

The programmer tests the program once, using the value 3, and it works. The programmer decides that no more testing is needed.

(a) Explain why testing with only one normal value is not enough. [2]

(b) Give two further test values, of different types of test data, that the programmer should use. For each value, state what it would check. [2]

9Grade 8–96 marks

The function countVowels should return the number of vowels (a, e, i, o, u) in a word, regardless of whether the letters are upper or lower case.

01 function countVowels(word)
02     count = 0
03     for i = 0 to word.length - 1
04         if word[i] == "a" OR word[i] == "e" OR word[i] == "i" OR word[i] == "o" OR word[i] == "u" then
05             count = count + 1
06         endif
07     next i
08     return count
09 endfunction

(a) Complete the Actual output column of the test plan by tracing the function as it is written. [3]

TestTest dataExpected outputActual output
1"cat"1 
2"queue"4 
3"Apple"2 

(b) Identify the test that fails and explain the cause of the error. [2]

(c) Write a corrected version of line 04 that fixes the error. [1]

10Grade 6–75 marks

A tester is checking a parking-payment program which asks for the number of hours to pay for. When the tester types ten, the program crashes with the message ValueError: invalid literal for int().

(a) State the type of test data the tester used. [1]

(b) Explain why the program should be tested with this data even though a customer is not expected to type a word. [2]

(c) The programmer fixes the problem. Describe what the tester should do after the fix has been made, and why. [2]

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