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
- Boundary
- Extreme
- Abnormal
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 is unexpected and needs to be handled appropriately.
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)
- Zero length string input (e.g. “”)
Boundary
Boundary 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 sits 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.
Extreme
Extreme test data
This is data outside of the limits of acceptable data and should be handled appropriately.
For example:
- 500
- -50
Resources