← VCE Software Development U3O1

Test cases: input, expected output, actual output

A chosen input paired with the output you expect. Run the algorithm, record the actual output, then compare: if actual matches expected it passes, otherwise it fails.

Understanding Test cases: input, expected output, actual output in VCE Software Development U3O1

What it does: The expected column is filled in by reasoning about the problem first, so it is an independent check on what the algorithm actually does. These four columns record each test case: what you put in, what you predicted, what really happened, and the pass or fail judgement. A test case pairs an input with the EXPECTED output. The actual output is only recorded after you run the algorithm. Doubling 7 gives 7 x 2 = 14. 49 is 7 squared, which is a different calculation.

Common mistakes: Assignment goes from the value to the variable. The chosen test input should be stored with input <- 5, not 5 <- input. The expected output must be worked out before running the algorithm (here input + 3). Using the algorithm to produce it means the test can never find an error.

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 168–177) and word search (Modules 168–193).

Take this worksheet further — free with Cloodit

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

Learning
Duo
Which two things does a test case pair together?
A chosen input and the output you expectA chosen input and the output you happened to get
Matches
Input: 40 | Expected: (copied from the program's output after running it)
↓
The expected output was taken from the program's actual output instead of being worked out beforehand, so the test cannot find mistakes.
Applying
Meanings
Term
test case
Meaning
A chosen input paired with the output you expect. Run the algorithm, record the actual output, then compare: if actual matches expected it passes, otherwise it fails.
Practice
Test | Input | Expected | Actual | Result
Testing
Gaps
Input | | Actual | Result
Check Answer
Spots
15 <- input
2expected <- input * 2

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

The 'Cosmic Owl' badge — Comprehension Guru, 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. Which two things does a test case pair together?
A. A chosen input and the output you happened to get
B. A chosen input and the output you expect ✓
A test case pairs an input with the EXPECTED output. The actual output is only recorded after you run the algorithm.
2. When should you work out the expected output?
A. Before running the algorithm ✓
B. After running, by copying what the algorithm printed
Work out the expected output first, using the problem rules. If you copy the actual output, you can never find a mistake.
3. An algorithm doubles a number. For the input 7, which expected output is correct?
A. 14 ✓
B. 49
Doubling 7 gives 7 x 2 = 14. 49 is 7 squared, which is a different calculation.
4. Which set of test table columns is the most useful?
A. Name, Date, Colour, Size
B. Input, Expected output, Actual output, Pass/Fail ✓
A test table records the input, the expected output, the actual output, and whether the test passed or failed.
5. The expected output is 20 and the actual output is 20. What is the result?
A. Pass ✓
B. Fail
When the actual output matches the expected output, the test case passes.

Match the Pairs

Input: 15 | Expected: Pass | Actual: Pass → The actual output matched the expected output, so this test case passes.
Input: 15 | Expected: Pass | Actual: Fail → The actual output did not match the expected output, so this test case fails and the algorithm needs checking.
Work out the expected output BEFORE running the algorithm, using the rules of the problem (e.g. a score of 50 or more is a pass). → Input: 72 | Expected: Pass
A test table has columns for the input, the expected output, the actual output and whether the test passed or failed. → | Input | Expected | Actual | Result |
Input: 40 | Expected: (copied from the program's output after running it) → The expected output was taken from the program's actual output instead of being worked out beforehand, so the test cannot find mistakes.
Input: 50 | Expected: Pass | Actual: Fail | Result: Pass → The result is wrong because the actual output (Fail) does not match the expected output (Pass), so the result should be Fail.

Key Term

test case
A chosen input paired with the output you expect. Run the algorithm, record the actual output, then compare: if actual matches expected it passes, otherwise it fails.

Fill in the Blanks

1. Input | Expected | Actual | Result
Hint: Type the column heading for the output you predict before running the algorithm.
2. if actual = expected then print "Pass" else print "Fail"
Hint: Type the comparison operator that checks whether the two values are equal.
3. n ← 5 expected ← n * 2 print expected
Hint: Type the operator that works out the doubled value by hand.
4. Input 7 | Expected 14 | Actual 13 | Fail
Hint: Type the result word for a test where the two outputs do not match.
5. n ← 4 actual ← double(n) print actual
Hint: Type the variable name that stores the output the algorithm really gave.

Spot the Error

Question 1
A 5 <- input
B expected <- input * 2
C actual <- double(input)
D if actual = expected then
E print PASS
Line A — Assignment goes from the value to the variable. The chosen test input should be stored with input <- 5, not 5 <- input.
Question 2
A input <- 7
B expected <- addThree(input)
C actual <- addThree(input)
D if actual = expected then
E print PASS
Line B — The expected output must be worked out before running the algorithm (here input + 3). Using the algorithm to produce it means the test can never find an error.
Question 3
A Input|Expected|Actual|Result
B 4|8|8|PASS
C 6|12|10|PASS
D 9|18|18|PASS
Line C — The expected output (12) does not match the actual output (10), so this test case fails. The result should be FAIL.
Question 4
A Algorithm: grade(mark)
B Input: A
C Expected output: A
D Actual output: A
Line B — The algorithm takes a mark as input, so the input should be a number such as 85. The letter A is the expected output, not the input.
Question 5
A actual <- isEven(9)
B expected <- true
C if actual = expected then
D print PASS
E else
F print FAIL
Line B — 9 is an odd number, so the expected output of isEven(9) should be false. Working out expected output wrongly gives a misleading test result.

Student with a class code? Join your class →