← ACARA Digital Technologies Years 9–10

Retesting everything after a fix

After fixing a bug, rerun the failed test and all earlier tests, because a fix can break code that used to pass.

Understanding Retesting everything after a fix in ACARA Digital Technologies Years 9–10

What it does: The test that failed earlier is run again on the fixed code. If it now prints True, the fix worked. This test passed before the change. After the fix it fails, which shows why every earlier test must be rerun. Code is connected. Changing one line can change how other parts behave, which is why we retest. Regression means going backwards. You check that the program has not slipped back into failing. A previously passing test that now fails is a regression. The fix needs another look. Even a small change like an operator can affect results for other test values.

Common mistakes: After a fix you must rerun the failed test AND all the earlier tests. This list only holds the one test that failed, so the earlier test (0, 0) is never rerun. It should be tests = [(0, 0), (3, 6)]. The slice [:1] keeps only the first test, so the rest are skipped after the fix. The loop should go through every test: for n, e in tests:.

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 591–622) and word search (Modules 536–622).

Take this worksheet further — free with Cloodit

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

Learning
Duo
You fix a bug and the test that failed now passes. What should you do next?
Rerun the failed test and all the earlier testsStop testing because the bug is fixed
Matches
Fix bug -> rerun only the failed test -> release the program
↓
Only the failed test was rerun. The earlier tests were skipped, so the fix may have broken something that used to pass.
Applying
Meanings
Term
regression testing
Meaning
After fixing a bug, rerun the failed test and all earlier tests, because a fix can break code that used to pass.
Practice
def grade(m):
Testing
Gaps
for n, expected in :
Check Answer
Spots
1def double(n): return n * 2
2tests = [(3, 6)]

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

The 'Moose' badge — Tundra Champion, 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. You fix a bug and the test that failed now passes. What should you do next?
A. Stop testing because the bug is fixed
B. Rerun the failed test and all the earlier tests ✓
A fix can break something that used to work, so you rerun every test, not just the one that failed.
2. True or false: A fix to one part of a program can cause a test that used to pass to fail.
A. True ✓
B. False
Code is connected. Changing one line can change how other parts behave, which is why we retest.
3. Which one describes regression testing?
A. Rerunning old tests after a change to check nothing that used to pass has broken ✓
B. Writing brand new tests for a program you have not run yet
Regression means going backwards. You check that the program has not slipped back into failing.
4. Mia fixes a bug in a discount function. Which retest plan is best?
A. Rerun the failed test plus every earlier test ✓
B. Rerun only the test that failed
Rerunning only the failed test can miss new bugs the fix has caused in tests that passed before.
5. After a fix, Test 3 now passes but Test 1, which passed yesterday, now fails. What does this show?
A. Test 1 must be wrong and can be ignored
B. The fix broke code that used to work ✓
A previously passing test that now fails is a regression. The fix needs another look.

Match the Pairs

regression testing → Rerunning the failed test and all the earlier tests after a fix, to check nothing that used to pass is now broken
for t in tests: run(t) → Rerun every saved test case after a fix, not just the one that failed
After fixing a bug, rerun the test that failed to check the fix actually worked → print(add(2, 3) == 5)
A fix can break code that used to pass, so an earlier passing test can now fail → print(is_even(4) == True) # passed before the fix, FAIL after
Fix bug -> rerun only the failed test -> release the program → Only the failed test was rerun. The earlier tests were skipped, so the fix may have broken something that used to pass.
Test 3 passes after the fix -> assume tests 1, 2 and 4 still pass → Assuming earlier tests still pass is wrong. A fix can break other code, so tests 1, 2 and 4 must be rerun and checked.

Key Term

regression testing
After fixing a bug, rerun the failed test and all earlier tests, because a fix can break code that used to pass.

Fill in the Blanks

1. tests = [(2, 4), (3, 9), (0, 0)] for n, expected in tests: print(square(n) == expected)
Hint: Type the variable that holds every test case, so the earlier tests are rerun too, not just the one that failed.
2. for n, expected in tests: if square(n) != expected: print("FAIL", n)
Hint: Type the comparison operator that is true when the actual result does not match the expected result, so a broken old test is caught.
3. def run_tests(): for n, e in tests: print(square(n) == e)
Hint: Type the keyword that defines a function, so the whole set of tests can be run again after every fix.
4. def square(n): return n * n run_tests()
Hint: After editing the function, type the name of the test function that reruns all the tests, to check the fix did not break anything.
5. def double(n): return n * 2 assert double(4) == 8
Hint: Type the expected result of this earlier test, which must still pass after a fix elsewhere in the program.

Spot the Error

Question 1
A def double(n): return n * 2
B tests = [(3, 6)]
C for n, e in tests:
D ok = double(n) == e
E print(n, ok)
Line B — After a fix you must rerun the failed test AND all the earlier tests. This list only holds the one test that failed, so the earlier test (0, 0) is never rerun. It should be tests = [(0, 0), (3, 6)].
Question 2
A def add_one(n): return n + 1
B tests = [(1, 2), (9, 10)]
C for n, e in tests[:1]:
D print(add_one(n) == e)
Line C — The slice [:1] keeps only the first test, so the rest are skipped after the fix. The loop should go through every test: for n, e in tests:
Question 3
A def square(n): return n * n
B for n, e in [(2, 4), (3, 9)]:
C if square(n) = e:
D print('PASS', n)
E else: print('FAIL', n)
Line C — A single = is assignment, not comparison, so this is a SyntaxError and no retests run. It should be if square(n) == e:
Question 4
A def double(n): return n + 3
B tests = [(0, 0), (3, 6)]
C for n, e in tests:
D print(double(n) == e)
Line A — This 'fix' makes the test 3 -> 6 pass but breaks 0 -> 0, which used to pass. That is why you rerun all earlier tests after a fix. The correct code is return n * 2.
Question 5
A def half(n): return n / 2
B tests = [(4, 2), (10, 5)]
C failed = 1
D for n, e in tests:
E if half(n) != e:
F failed += 1
Line C — The failure counter must start at 0 on every retest run. Starting at 1 reports a failure even when every test passes. It should be failed = 0.

Student with a class code? Join your class →