Constructing test data for validation checks

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Constructing test data for validation checks

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. A form requires a username (existence check). Which test value checks the rule?
A An empty string "" - expected result: rejected
B The string "Sam" - expected result: rejected
2. An age field must hold a whole number (type check). Which test value checks the rule?
A "abc" (text instead of a number) - expected result: accepted
B "abc" (text instead of a number) - expected result: rejected
3. A mark must be between 0 and 100 inclusive (range check). Which set tests the boundaries best?
A 5, 50, 60, 70
B -1, 0, 100, 101
4. A range check allows quantities from 1 to 10. What is the expected result for the test value 10?
A Accepted - it is the upper boundary and is inside the range
B Rejected - it is the upper boundary so it is outside the range
5. Which is a good test plan for a validation rule?
A One test per rule, each with an expected result of accepted or rejected
B One valid value for all rules, with no expected result written down

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1age = "" Atest_value = 100
2age = "abc" BTest data for a type check: text instead of a number that should be rejected
3Boundary test just inside the upper limit of a range of 1 to 100: expected result accepted CTest data for an existence check: an empty value that should be rejected
4Boundary test just outside the upper limit of a range of 1 to 100: expected result rejected DAll values are well inside the range. There are no boundary values (1, 100) and no invalid values (0, 101) to test the limits.
5Range 1-100 tests: 50, 60, 70 E25 is a number, so a type check for numbers would accept it. The test needs text such as "abc" to be rejected.
6Type check test: 25 (expected: rejected) Ftest_value = 101

Definitions

test data

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
# Range rule: 13 to 18 inclusive testBelow = __ # just outside the limit
2.
# Type rule: age must be a whole number testText = "twelve" # Expected result: ________
3.
# Existence rule: name must not be empty testName = "" hasValue = len(testName) > _
4.
# Range rule: 13 to 18 inclusive testUpper = __ # just inside the limit
5.
# Range rule: 13 to 18. Test value: 13 expected = "________"

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A ages = [17, 18, 65, 66]
B ages = [18, 19, 64, 65]
C ok = 18 <= a <= 65
D print(a, ok)
Question 2
A name = ""
B valid = len(name) == 0
C print("Expected: rejected")
D print("Actual:", valid)
Question 3
A entry = "25"
B valid = entry.isdigit()
C print("Expected: rejected")
Question 4
A lo = 1
B hi = 10
C test = 10
D print(lo <= test < hi)
Question 5
A test = ""
B ok = len(test) > 0
C expected = False
D print(ok = expected)

Answer Key

Constructing test data for validation checks
Section A: Quick Questions
Q1
A — An empty string "" - expected result: rejected
Q2
B — "abc" (text instead of a number) - expected result: rejected
Q3
B — -1, 0, 100, 101
Q4
A — Accepted - it is the upper boundary and is inside the range
Q5
A — One test per rule, each with an expected result of accepted or rejected
Section B: Match the Pairs
Q1
age = "" → Test data for an existence check: an empty value that should be rejected
Q2
age = "abc" → Test data for a type check: text instead of a number that should be rejected
Q3
Boundary test just inside the upper limit of a range of 1 to 100: expected result accepted → test_value = 100
Q4
Boundary test just outside the upper limit of a range of 1 to 100: expected result rejected → test_value = 101
Q5
Range 1-100 tests: 50, 60, 70 → All values are well inside the range. There are no boundary values (1, 100) and no invalid values (0, 101) to test the limits.
Q6
Type check test: 25 (expected: rejected) → 25 is a number, so a type check for numbers would accept it. The test needs text such as "abc" to be rejected.
Section C: Definitions
Q1
test data — Values chosen to test each validation rule: empty for existence, text for type, and values just inside and just outside range limits, each with an expected result.
Section D: Fill in the Blanks
Q1
# Range rule: 13 to 18 inclusive testBelow = 12 # just outside the limit
Q2
# Type rule: age must be a whole number testText = "twelve" # Expected result: rejected
Q3
# Existence rule: name must not be empty testName = "" hasValue = len(testName) > 0
Q4
# Range rule: 13 to 18 inclusive testUpper = 18 # just inside the limit
Q5
# Range rule: 13 to 18. Test value: 13 expected = "accepted"
Section E: Spot the Error
Q1
B — Boundary test data for a range of 18 to 65 needs values just outside the limits (17 and 66) as well as on them. This list only has accepted values, so it never tests rejection. It should be [17, 18, 65, 66].
Q2
B — An existence check must accept a value only when it is not empty. Using == 0 reverses the rule, so the empty test value would be accepted. It should be len(name) > 0.
Q3
A — Test data for a type check on a number must be text that is not a number, such as "abc". The value "25" is all digits, so it would be accepted and the expected result of rejected would be wrong.
Q4
D — The range check must include the upper limit. Using < hi rejects 10, which is a valid boundary value. It should be lo <= test <= hi.
Q5
D — To compare the actual result with the expected result, use the comparison operator ==. A single = is assignment, so inside print() it causes an error. It should be print(ok == expected).