Choosing a range of test data

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

Choosing a range of test data

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. An algorithm accepts quiz scores from 0 to 100. Which value is NORMAL data?
A 65
B -5
2. An algorithm accepts ages from 13 to 18. Which pair is BOUNDARY data?
A 13 and 18
B 15 and 16
3. A program should reject a mark of 150 when marks must be 0 to 100. What type of test data is 150?
A Normal data
B Invalid data
4. A login algorithm needs a password of 8 to 12 characters. Which is the better boundary test?
A A password with exactly 8 characters
B A password with 10 characters
5. An algorithm has three branches: 'Fail', 'Pass' and 'Distinction'. Which test set is better?
A Three test cases that all trigger 'Pass'
B One test case that triggers each branch

Match the Pairs

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

Left columnRight column
1score <- 50 Aage <- 16
2score <- -5 BAll values are normal data. There are no boundary tests (1, 100) and no invalid tests (0, 101), so the edges and rejection paths are never checked.
3Normal data is a typical value that sits well inside the allowed range CInvalid data: a value outside what is allowed, which the algorithm should reject
4One test case per branch: every path in the algorithm is run at least once Dif age < 13 then / else if age < 18 then / else
5Tests for a 1 to 100 range: 20, 45, 70 EBoth tests only run the Pass branch. The else branch (Fail) is never tested, so one path is left unchecked.
6Tests for if mark >= 50 then print Pass: 80 and 90 FBoundary data: a value exactly on the edge of a range, such as the pass mark in if score >= 50

Definitions

normal, boundary and invalid data

Fill in the Blanks

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

1.
if mark >= 50 then print "Pass" else print "Fail" // Boundary test: mark = __
2.
if mark < 0 or mark > 100 then print "Invalid" // Test mark = -5 is _______ data
3.
if mark >= 50 then print "Pass" else print "Fail" // Test mark = 70 is ______ data
4.
// Valid range: 1 to 10 // Invalid values: 0 and 11 // Boundary values: 1 and __
5.
if age >= 18 then print "Adult" else print "Minor" // Need _ tests: one for each branch

Spot the Error

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

Question 1
A input mark
B if mark < 0 or mark > 100 then
C print "Invalid"
D else if mark > 50 then
E print "Pass"
F else print "Fail"
Question 2
A Normal: 15 -> rejected
B Boundary: 13 -> accepted
C Boundary: 18 -> accepted
D Invalid: -4 -> rejected
Question 3
A Test 1: qty 5 -> full price
B Test 2: qty 10 -> bulk discount
C Test 3: qty 0 -> invalid
D Test 4: qty 9 -> bulk discount
Question 4
A input age
B while age < 0 and age > 120 do
C print "Enter 0 to 120"
D input age
Question 5
A Fail branch: mark 30 -> Fail
B Pass branch: mark 65 -> Pass
C Pass branch: mark 70 -> Pass
D Invalid: mark -3 -> Error

Answer Key

Choosing a range of test data
Section A: Quick Questions
Q1
A — 65
Q2
A — 13 and 18
Q3
B — Invalid data
Q4
A — A password with exactly 8 characters
Q5
B — One test case that triggers each branch
Section B: Match the Pairs
Q1
score <- 50 → Boundary data: a value exactly on the edge of a range, such as the pass mark in if score >= 50
Q2
score <- -5 → Invalid data: a value outside what is allowed, which the algorithm should reject
Q3
Normal data is a typical value that sits well inside the allowed range → age <- 16
Q4
One test case per branch: every path in the algorithm is run at least once → if age < 13 then / else if age < 18 then / else
Q5
Tests for a 1 to 100 range: 20, 45, 70 → All values are normal data. There are no boundary tests (1, 100) and no invalid tests (0, 101), so the edges and rejection paths are never checked.
Q6
Tests for if mark >= 50 then print Pass: 80 and 90 → Both tests only run the Pass branch. The else branch (Fail) is never tested, so one path is left unchecked.
Section C: Definitions
Q1
normal, boundary and invalid data — A good test set uses normal data (typical values), boundary data (values at the edges of a range) and invalid data (values that should be rejected), so every path in an algorithm is checked.
Section D: Fill in the Blanks
Q1
if mark >= 50 then print "Pass" else print "Fail" // Boundary test: mark = 50
Q2
if mark < 0 or mark > 100 then print "Invalid" // Test mark = -5 is invalid data
Q3
if mark >= 50 then print "Pass" else print "Fail" // Test mark = 70 is normal data
Q4
// Valid range: 1 to 10 // Invalid values: 0 and 11 // Boundary values: 1 and 10
Q5
if age >= 18 then print "Adult" else print "Minor" // Need 2 tests: one for each branch
Section E: Spot the Error
Q1
D — The boundary value 50 would fall through to Fail, because > excludes 50. A mark of exactly 50 should pass, so the line should be: else if mark >= 50 then.
Q2
A — Boundary tests 13 and 18 are both accepted, so 15 lies inside the valid range and is normal data. Its expected result should be accepted, not rejected.
Q3
D — Test 2 shows the bulk discount starts at exactly 10. The value just below the boundary, 9, should give full price, not a bulk discount.
Q4
B — No number is both below 0 and above 120, so the loop never runs and invalid data is never rejected. The condition should use or: while age < 0 or age > 120 do.
Q5
C — This line tests the Pass branch a second time, so the Merit branch is never tested. There should be one case per branch, so it should be: Merit branch: mark 90 -> Merit.