← Years 5–6 Creating Digital Solutions

Testing a visual program

Running your program with chosen test inputs and comparing what happens to the result you expected. Test every path, so each branch of the program gets checked.

Understanding Testing a visual program in Years 5–6 Creating Digital Solutions

What it does: An if-else block has two paths. One test input for each path makes sure both branches get checked. When you run the test, you compare what really happened with what you expected. If they match, the test passes. A test input is the value you give the program when you run it, like typing 5 when it asks. One matching result only shows that one path works. Other paths still need testing. A mismatch shows there may be a bug. Debug the program instead of changing the expected result. Run your tests again to check the fix worked and did not break another path.

Common mistakes: The rule says a score over 10 says Win. The test input is 15, so the expected result must be say Win, not say Lose. The expected result is say Child, but age 20 is not under 13. The test input should be a number below 13, such as 8.

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 61–74) and word search (Modules 41–74).

Take this worksheet further — free with Cloodit

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

Learning
Duo
What is testing a program?
Reading the blocks once and hoping they are rightRunning it with chosen inputs and comparing what happens to what you expected
Matches
Only test: age = 15 (if path only)
↓
Only one path was tested. The else path was never checked, so a mistake there could be missed. Add a test input such as age = 8.
Applying
Meanings
Term
testing
Meaning
Running your program with chosen test inputs and comparing what happens to the result you expected. Test every path, so each branch of the program gets checked.
Practice
Program: if answer < 13 say Too young else say Welcome
Testing
Gaps
result: say Adult
Check Answer
Spots
2Test input: score = 15
3Expected: say Lose

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

The 'Silverback Gorilla' badge — Savannah Master, 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. What is testing a program?
A. Reading the blocks once and hoping they are right
B. Running it with chosen inputs and comparing what happens to what you expected ✓
Testing means you actually run the program with test inputs and check the result against what you expected.
2. Which one is a test input for a quiz program that asks for a number between 1 and 10?
A. Typing 5 into the ask box ✓
B. Changing the sprite's costume
A test input is the value you give the program when you run it, like typing 5 when it asks.
3. When should you work out the expected result?
A. Before you run the test ✓
B. After you see what the program does
Decide what should happen first. Then you can fairly compare it to what really happens.
4. A program says 'You pass!' if score > 50. You test with a score of 80 and expect 'You pass!'. It says 'You pass!'. What does this tell you?
A. The whole program is now fully tested
B. The result matched, so this path works ✓
One matching result only shows that one path works. Other paths still need testing.
5. A program has an if-else block. How many paths do you need to test?
A. Both the if path and the else path ✓
B. Only the if path
Test every path so each branch gets checked. An if-else has two branches.

Match the Pairs

Test input: age = 8 → A chosen value you give the program to see how it behaves
Expected: say "Too young" → What you predict the program should do before you run it
Testing every path means trying an input for each branch of an if-else block → Test 1: age = 15 (if path) Test 2: age = 8 (else path)
Testing means comparing the actual result with the expected result → Expected: 10, Actual: 10 -> Pass
Only test: age = 15 (if path only) → Only one path was tested. The else path was never checked, so a mistake there could be missed. Add a test input such as age = 8.
Run the program and see what happens (no expected result) → No expected result was written first, so you cannot tell if the program is right or wrong. Decide what should happen before you run it.

Key Term

testing
Running your program with chosen test inputs and comparing what happens to the result you expected. Test every path, so each branch of the program gets checked.

Fill in the Blanks

1. Test input: 20 Expected result: say Adult
Hint: Type the word for what you predict the program will do before you run it.
2. Test input: 10 Expected result: say Child
Hint: Type the word for the value you give the program when you test it.
3. Test 1: age 20 checks the IF path Test 2: age 10 checks the ELSE path
Hint: Type the keyword for the branch that runs when the condition is false.
4. ask [Enter your age] and wait if <answer > 17> then say [Adult]
Hint: Type the name of the block that holds the test input the user typed.
5. Expected: say Adult Actual: say Child Result: FAIL
Hint: Type the word for what the program really did when you ran it.

Spot the Error

Question 1
A Rule: if score > 10, say Win
B Test input: score = 15
C Expected: say Lose
D Actual: say Win
Line C — The rule says a score over 10 says Win. The test input is 15, so the expected result must be say Win, not say Lose.
Question 2
A Rule: if age < 13, say Child
B Test input: age = 20
C Expected: say Child
Line B — The expected result is say Child, but age 20 is not under 13. The test input should be a number below 13, such as 8.
Question 3
A Rule: if lives = 5, game over
B Test input: lives = 0
C Expected: say Game over
Line A — The test uses lives = 0 and expects Game over, so the rule must check for lives = 0. Checking for 5 would not match the test.
Question 4
A Rule: >10 says Win, else Try
B Test 1: score = 20, expect Win
C Test 2: score=30, expect Win
Line C — Both tests now use the Win path, so the else path is never checked. Test 2 should use a small score like 4 to test the Try path.
Question 5
A set score to 0
B repeat 5
C change score by 2
D Expected: score is 6
Line B — Repeating 5 times adds 2 each time, so the score would be 10, not the expected 6. The loop should be repeat 3.

Student with a class code? Join your class →