Test Data (SQA National 5 Computing Science): Revision Note

Exam code: X816 75

Robert Hampton

Written by: Robert Hampton

Reviewed by: James Woodhouse

Updated on

Suitable test data

What is suitable test data?

  • Suitable test data is specially chosen to check that a program works correctly and produces the expected results in all situations

  • During testing, the actual results are compared to the expected results to make sure the program behaves as intended

  • Students must be able to describe, identify, exemplify, and implement the three main categories of test data:

    • Normal

    • Extreme

    • Exceptional

Example

  • The following example checks if a user’s age is between 12 and 18

RECEIVE name FROM (STRING) KEYBOARD
RECEIVE age FROM (INTEGER) KEYBOARD

IF age >= 12 AND age <= 18 THEN
    SEND "Welcome " & name & ". Your age is accepted." TO DISPLAY
ELSE
    SEND "Sorry " & name & ". Your age is not accepted." TO DISPLAY
END IF

In Python, the same program would be:

name = input("What is your name? ")
age = int(input("How old are you? "))

if age >= 12 and age <= 18:
    print("Welcome,", name + "! Your age is accepted.")
else:
    print("Sorry,", name + ". Your age is not accepted.")

Normal test data

  • Normal test data is data that should be accepted by the program

  • It lies within the valid range and is of the correct data type

  • Example:

    • Input → 16

    • Expected output → “Accepted”

Extreme test data

  • Extreme test data is the lowest and highest values of valid data that should still be accepted by the program

  • Example:

    • Input → 12 or 18

    • Expected output → “Accepted”

Exceptional test data

  • Exceptional test data is data that is invalid and should be rejected by the program

  • This could be the wrong data type, outside the valid range, or missing input

  • Example:

    • Input → “F” or 11 or 19

    • Expected output → “Rejected”

Selecting suitable test data

Type of test

Input

Expected result

Normal

14

Accepted

Normal

16

Accepted

Extreme

12

Accepted

Extreme

18

Accepted

Exceptional

H

Rejected

Exceptional

@

Rejected

Exceptional

11

Rejected

Exceptional

19

Rejected

  • Using different categories of test data ensures that the program works correctly for valid inputs and handles invalid inputs without crashing

Worked Example

A programmer is developing an application that records scores for a school competition. The system requires the user to input a Project Mark.

The Project Mark must be a whole number (integer) between 1 and 20, inclusive. If the input is invalid, an error message must be displayed.

Complete the test table below with suitable input values and the expected results required to fully test the input validation for the Project Mark.

Type of test

Input

Expected result

Extreme (Upper Limit)

Program continues

Exceptional (Below range)

Program displays an error message

Exceptional (Invalid type)

Program displays an error message

[3]

Answer

Type of test

Input

Expected result

Extreme (Upper Limit)

20 [1 mark]

Program continues

Exceptional (Below range)

0 or -5 (any integer < 1) [1 mark]

Program displays an error message

Exceptional (Invalid type)

"twenty" or 2.5 (non-integer/text) [1 mark]

Program displays an error message

  • Alternative extreme:

    • 1 - Program continues [1 mark]

Unlock more, it's free!

Join the 100,000+ Students that ❤️ Save My Exams

the (exam) results speak for themselves:

Robert Hampton

Author: Robert Hampton

Expertise: Computer Science Content Creator

Rob has over 16 years' experience teaching Computer Science and ICT at KS3 & GCSE levels. Rob has demonstrated strong leadership as Head of Department since 2012 and previously supported teacher development as a Specialist Leader of Education, empowering departments to excel in Computer Science. Beyond his tech expertise, Robert embraces the virtual world as an avid gamer, conquering digital battlefields when he's not coding.

James Woodhouse

Reviewer: James Woodhouse

Expertise: Computer Science & English Subject Lead

James graduated from the University of Sunderland with a degree in ICT and Computing education. He has over 14 years of experience both teaching and leading in Computer Science, specialising in teaching GCSE and A-level. James has held various leadership roles, including Head of Computer Science and coordinator positions for Key Stage 3 and Key Stage 4. James has a keen interest in networking security and technologies aimed at preventing security breaches.