Skip to content
Learnearn.uk » A Level Computer Science Home » Choosing Test Data

Choosing Test Data

Testing Data

Choosing Testing Data

It is important that you choose test data that simulates a wide variety of usage and especially that you choose data that tests the three types of test data:

  • Normal
  • Abnormal
  • Boundary / Extreme

When White Box Testing, as you have access to the source code, you should ensure that your test data covers all the possible programs paths for that function or module.

Example

age = input("How old are you?")
if not age.isdigit():
    print("Age must be a whole number")
elif int(age) < 0:
    print("Age must be greater than or equal to zero")
elif int(age) < 10:
	print("You are young")
elif int(age) > 70:
	print("You are old!")
else:
	print("You are a normal age")

In the code above there are 5 possible paths in the program to test and so your test data should probably include values  such as:

  • 2.5
  • -1
  • 5
  • 20
  • 100

Normal

Normal Data

Normal Data is data that you would usually expect to be input within reasonable bounds.

For a user’s age, you would probably expect a whole number between 10 and 80

 

Abnormal

Abnormal Test Data

This is test data that you would deem invalid and should be handled appropriately. It is important to use a variety of different invalid data checks.

For a user’s age, you should check:

  • Float style input (e.g.  2.5)
  • Character input (e.g. twenty five)
  • Mixed input( e.g. 25 Years Old)
  • Out of bounds input ( e.g.   -5  or 300)
  • Zero length string input (e.g. “”)

Boundary / Extreme

Boundary / Extreme Test Data

Boundary test data incorporates two main areas:

  • The data at the very limits of what is deemed normal, to ensure that is allowed (but perhaps with a warning/notification)
  • Data that sites on the boundary between two normal ranges, to ensure that the program branches correctly.

Boundary test data is extremely important as often logical errors can be found are boundaries.

Example

try:
	temp = int(input("What is the temperature?"))
	
	if temp < 0:
		print("It's freezing!")
	elif temp > 0:
		print("It's not freezing:")
	
except:
	print("Invalid temperature")

In the code above a subtle error has been included in the code. If the user inputs the temperature as 0, then nothing at all will be printed out. This error would be highlighted if boundary test data is included.

Resources