Test Data (SQA National 5 Computing Science): Revision Note
Exam code: X816 75
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 IFIn 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!
Did this page help you?