← ACARA Digital Technologies Years 5–6

Testing an algorithm with different starting values

A chosen starting value you try in an algorithm, with the result you expect. Use one for every path and for a loop that runs zero times, then compare expected and actual results.

Understanding Testing an algorithm with different starting values in ACARA Digital Technologies Years 5–6

What it does: The tester writes down the expected result, runs the algorithm to get the actual result, and a mismatch shows a bug. One value that makes the condition true and one that makes it false test both paths of the decision. Age 8 uses the ELSE path and age 15 uses the THEN path. 15 and 20 both take the THEN path, so the ELSE path is never tested. When the expected and actual results are different, the test has found a problem. Check the steps to find the mistake. Each path needs its own test value, for example 30, 65 and 90. One value only tests one path.

Common mistakes: The rule says 50 or more is a Pass, so the test case with score 50 should expect Pass, not Fail. Repeating n + 1 times would say Hello once even when n is 0. The loop should repeat n TIMES so it runs zero times for 0.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 120–132) and word search (Modules 106–132).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
An algorithm says: IF age >= 13 THEN say 'Teen ticket' ELSE say 'Child ticket'. Which test values check BOTH paths?
Test with age 8 and age 15Test with age 15 and age 20
Matches
IF age >= 12 THEN ... ELSE ... Test: age = 15 only
↓
Only the THEN path is tested. The ELSE path is never tried, so a mistake there would be missed. Add a test such as age = 8.
Applying
Meanings
Term
test case
Meaning
A chosen starting value you try in an algorithm, with the result you expect. Use one for every path and for a loop that runs zero times, then compare expected and actual results.
Practice
ASK for mark
Testing
Gaps
TEST count ← , expected: no "Hi"
Check Answer
Spots
1RULE: 50 or more is a Pass
2TEST score 50, EXPECT Fail

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Barreleye Fish' badge — Clear Vision, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. An algorithm says: IF age >= 13 THEN say 'Teen ticket' ELSE say 'Child ticket'. Which test values check BOTH paths?
A. Test with age 15 and age 20
B. Test with age 8 and age 15 ✓
Age 8 uses the ELSE path and age 15 uses the THEN path. 15 and 20 both take the THEN path, so the ELSE path is never tested.
2. Why do we test an algorithm with several different starting values?
A. To check that every decision path and repeat works ✓
B. To make the algorithm run faster
Different starting values send the algorithm down different paths. Testing them all shows whether each path works.
3. Before you run a test, what should you write down?
A. Only the result the algorithm gives
B. The result you expect to get ✓
A test case has a starting value AND an expected result. After the test you compare the expected result with the actual result.
4. An algorithm says: REPEAT UNTIL count = 0. You test it with a starting count of 0. What should you expect?
A. The loop runs zero times ✓
B. The loop runs one time
The condition is already true at the start, so the loop body is skipped. Testing a loop that runs zero times is a good test.
5. You expected the answer 12, but the algorithm gave 10. What does this tell you?
A. There may be a mistake to find and fix ✓
B. The test passed, so nothing is wrong
When the expected and actual results are different, the test has found a problem. Check the steps to find the mistake.

Match the Pairs

Test 1: input 15, expect "Pass" Test 2: input 3, expect "Try again" → A test case for each path of an IF ... ELSE, so both the THEN path and the ELSE path get checked
Test: REPEAT count times, count = 0 Expect: loop body never runs → A test case for a loop that runs zero times, to check the steps inside are skipped
Comparing expected and actual results: if they do not match, the algorithm has a mistake to fix → Expected: 10 Actual: 8 Result: FAIL
A test for every path: pick starting values so each branch of the decision is used → IF score >= 50 THEN Test with score = 70 ELSE Test with score = 20
IF age >= 12 THEN ... ELSE ... Test: age = 15 only → Only the THEN path is tested. The ELSE path is never tried, so a mistake there would be missed. Add a test such as age = 8.
REPEAT n times Test: n = 5 only Expect: it runs 5 times → The loop is never tested with a start value of 0, so we do not know if it correctly runs zero times. Add a test with n = 0.

Key Term

test case
A chosen starting value you try in an algorithm, with the result you expect. Use one for every path and for a loop that runs zero times, then compare expected and actual results.

Fill in the Blanks

1. REPEAT count TIMES OUTPUT "Hi" TEST count ← 0, expected: no "Hi"
Hint: Type the starting value that makes the loop run zero times.
2. SET expected ← 10 SET actual ← 10 IF actual = expected THEN OUTPUT "Pass"
Hint: Type the symbol that checks whether the actual result is the same as the expected result.
3. IF temp > 30 THEN OUTPUT "Hot" ELSE OUTPUT "Mild" Test temp ← 20 uses the ELSE path
Hint: Type the keyword for the path that runs when the condition is false.
4. IF n > 0 THEN OUTPUT "Positive" ELSE OUTPUT "Not positive" TEST n ← 0, expected "Not positive"
Hint: Type the name of the variable that the algorithm checks, so the test case sets its starting value.
5. FOR EACH test IN testList IF actual ≠ expected THEN OUTPUT "Fix the algorithm"
Hint: Type the symbol that means the actual result is not equal to the expected result.

Spot the Error

Question 1
A RULE: 50 or more is a Pass
B TEST score 50, EXPECT Fail
C TEST score 49, EXPECT Fail
Line B — The rule says 50 or more is a Pass, so the test case with score 50 should expect Pass, not Fail.
Question 2
A SET n TO 0
B REPEAT n + 1 TIMES
C SAY Hello
D EXPECT: no Hello when n is 0
Line B — Repeating n + 1 times would say Hello once even when n is 0. The loop should repeat n TIMES so it runs zero times for 0.
Question 3
A TEST lives=3, EXPECT Lose
B IF lives = 0 THEN
C SAY Lose
D ELSE SAY Play on
Line A — With lives=3 the algorithm goes to the ELSE path and says Play on. To test the Lose path, the starting value must be lives=0.
Question 4
A EXPECTED: 12
B ACTUAL: 10
C They differ: the test passed
D Fix the algorithm, then retest
Line C — When the expected and actual results are different, the test has failed and shows a bug. It should say there is a bug.
Question 5
A IF temp > 30 SAY Hot
B ELSE IF temp > 15 SAY Mild
C ELSE SAY Cold
D TESTS: 35, 40, 50
Line D — 35, 40 and 50 all take the Hot path, so Mild and Cold are never tested. Choose one value for each path, such as 35, 20 and 5.

Student with a class code? Join your class →