Choosing test data for compound conditions

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

This Choosing test data for compound conditions worksheet is part of the ACARA Digital Technologies Years 9–10 — Algorithms with Logical Operators journey. Print it as a booklet?

Choosing test data for compound conditions

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. A rule says: IF Age >= 18 AND HasLicence = TRUE. Which set of Age values best tests the boundary?
A 17, 18 and 19
B 5, 30 and 80
2. For IF Age >= 18 AND HasLicence = TRUE, how many combinations of the two parts should you test?
A 2 (both TRUE and both FALSE)
B 4 (TRUE/TRUE, TRUE/FALSE, FALSE/TRUE, FALSE/FALSE)
3. Which test data makes only the FIRST part of IF Age >= 18 AND HasLicence = TRUE fail?
A Age = 17, HasLicence = TRUE
B Age = 19, HasLicence = FALSE
4. Which statement about testing a compound condition is correct?
A Make each part TRUE and FALSE in turn so every path is tested
B One test where the whole condition is TRUE is enough
5. Age is tested with Age >= 18. Which value is the most important boundary test?
A 100
B 18

Match the Pairs

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

Left columnRight column
1Age ← 17 AA boundary test value exactly on the limit, so Age >= 18 is TRUE
2Age ← 18 BNo test data is on the boundary. Values 17, 18 and 19 are missing, so an error like > 18 would not be found.
3Test all four combinations of two parts: TRUE/TRUE, TRUE/FALSE, FALSE/TRUE and FALSE/FALSE COne value only makes both parts TRUE. It never tests a FALSE part, so most paths are untested.
4Test the loop so it runs zero times, because the condition is FALSE the first time DCount ← 10 then WHILE Count < 5
5Test only Age = 25 for IF Age >= 18 AND Age <= 65 EAge ← 20, HasTicket ← FALSE
6Test Age = 10, 15 and 30 for IF Age >= 18 FA boundary test value just below the limit, so Age >= 18 is FALSE

Definitions

test data

Fill in the Blanks

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

1.
IF Age >= 18 THEN Test Age: __, 18, 19
2.
IF Age >= 18 AND HasLicence = TRUE THEN Test: Age = 20, HasLicence = _____
3.
IF Age < 13 OR Age > 65 THEN Test Age = 40: both parts are _____
4.
WHILE Lives > 0 AND Time > 0 DO Test: Lives = _, so loop runs zero times
5.
IF A AND B THEN Two parts, each TRUE or FALSE, need _ tests

Spot the Error

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

Question 1
A Rule: Age >= 18 AND Paid = YES
B T1: Age 18, Paid YES -> TRUE
C T2: Age 17, Paid YES -> TRUE
D T3: Age 18, Paid NO -> FALSE
Question 2
A IF Age > 18 THEN
B T1: Age 17 -> FALSE
C T2: Age 18 -> TRUE
D T3: Age 19 -> TRUE
Question 3
A WHILE N < 5 AND Go = YES DO
B N <- N + 1
C ENDWHILE
D Test N=5: runs 1 time
Question 4
A Rule: Rain OR Wind
B T1: Rain=T, Wind=T -> TRUE
C T2: Rain=T, Wind=F -> FALSE
D T3: Rain=F, Wind=T -> TRUE
E T4: Rain=F, Wind=F -> FALSE
Question 5
A Rule: Age >= 18
B Boundary tests: 10, 30, 50
C Expect: FALSE, TRUE, TRUE

Answer Key

Choosing test data for compound conditions
Section A: Quick Questions
Q1
A — 17, 18 and 19
Q2
B — 4 (TRUE/TRUE, TRUE/FALSE, FALSE/TRUE, FALSE/FALSE)
Q3
A — Age = 17, HasLicence = TRUE
Q4
A — Make each part TRUE and FALSE in turn so every path is tested
Q5
B — 18
Section B: Match the Pairs
Q1
Age ← 17 → A boundary test value just below the limit, so Age >= 18 is FALSE
Q2
Age ← 18 → A boundary test value exactly on the limit, so Age >= 18 is TRUE
Q3
Test all four combinations of two parts: TRUE/TRUE, TRUE/FALSE, FALSE/TRUE and FALSE/FALSE → Age ← 20, HasTicket ← FALSE
Q4
Test the loop so it runs zero times, because the condition is FALSE the first time → Count ← 10 then WHILE Count < 5
Q5
Test only Age = 25 for IF Age >= 18 AND Age <= 65 → One value only makes both parts TRUE. It never tests a FALSE part, so most paths are untested.
Q6
Test Age = 10, 15 and 30 for IF Age >= 18 → No test data is on the boundary. Values 17, 18 and 19 are missing, so an error like > 18 would not be found.
Section C: Definitions
Q1
test data — Values chosen so each part of a compound condition is TRUE and FALSE in turn, including boundaries like 17, 18 and 19 for Age >= 18, so every path gets tested.
Section D: Fill in the Blanks
Q1
IF Age >= 18 THEN Test Age: 17, 18, 19
Q2
IF Age >= 18 AND HasLicence = TRUE THEN Test: Age = 20, HasLicence = FALSE
Q3
IF Age < 13 OR Age > 65 THEN Test Age = 40: both parts are FALSE
Q4
WHILE Lives > 0 AND Time > 0 DO Test: Lives = 0, so loop runs zero times
Q5
IF A AND B THEN Two parts, each TRUE or FALSE, need 4 tests
Section E: Spot the Error
Q1
C — Age 17 makes Age >= 18 FALSE, so the whole AND is FALSE even though Paid is YES. The expected result should be FALSE.
Q2
A — The boundary test with Age 18 expects TRUE, but > 18 makes 18 FALSE. The condition should be Age >= 18.
Q3
D — When N is 5, N < 5 is FALSE before the first check, so the loop body runs 0 times. The test note should say it runs 0 times.
Q4
C — OR is TRUE when at least one part is TRUE. Rain=T makes the whole condition TRUE, so the expected result is TRUE.
Q5
B — These values are far from the boundary and never test 18 itself. Good test data uses 17, 18 and 19.