← VCE Software Development U3O1

Automated test generation with AI tools

AI can draft assert tests for a module, but you must check each expected output by hand to be sure it is correct. Also add any normal, boundary or invalid cases it missed.

Understanding Automated test generation with AI tools in VCE Software Development U3O1

What it does: A good prompt names the types of test wanted, so the AI drafts a wider range of cases. Working the calculation out by hand shows the AI expected value is wrong (it should be 30), so the test must be fixed. Passing tests only show the code matches what the tests expect. Wrong expected values or missing cases can hide bugs. -5 is outside the allowed range, so it tests how the function handles invalid input. 85 is a normal value. A test runner runs every test each time and reports passes and failures, so you can re-test quickly after changes.

Common mistakes: The AI's expected output is wrong. The function uses >= 18, so age 18 is an adult and the boundary test must expect True. Always check each expected value by hand. => is not a valid Python comparison operator, so this is a syntax error. It should be >=.

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 178–193) 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
An AI tool writes assert calculate_gst(100) == 10 for your function. What should you do before trusting this test?
Trust it because the AI wrote it, so it must be correctCheck the expected output by hand to confirm it is correct
Matches
assert get_grade(50) == 'F' # copied from AI, never checked
↓
The expected output was trusted without being checked against the requirement, so the test may be wrong
Applying
Meanings
Term
assert
Meaning
AI can draft assert tests for a module, but you must check each expected output by hand to be sure it is correct. Also add any normal, boundary or invalid cases it missed.
Practice
def grade(mark):
Testing
Gaps
add(2, 3) == 5
Check Answer
Spots
2 return age >= 18
3assert is_adult(18) == False

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

The 'Angelfish' badge — Reef Perfectionist, 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 AI tool writes assert calculate_gst(100) == 10 for your function. What should you do before trusting this test?
A. Check the expected output by hand to confirm it is correct ✓
B. Trust it because the AI wrote it, so it must be correct
AI can produce wrong expected outputs. You are responsible for checking each one by hand before relying on the test.
2. Which prompt is better for getting a full set of tests from an AI tool?
A. Write a test for my function
B. Write assert tests for is_valid_age(age) with normal, boundary and invalid values ✓
A specific prompt that asks for normal, boundary and invalid cases gives a wider range of test data.
3. A function accepts marks from 0 to 100. The AI only tests 50, 60 and 75. What is missing?
A. Nothing, because three tests is always enough
B. Boundary values (0 and 100) and invalid values (-1 and 101) ✓
Good test data includes normal, boundary and invalid cases. You should add any the AI missed.
4. True or false: if the AI-generated assert tests all pass, the module must be correct.
A. False: the tests might have wrong expected outputs or miss cases ✓
B. True: passing tests prove the code is correct
Passing tests only show the code matches what the tests expect. Wrong expected values or missing cases can hide bugs.
5. The AI writes assert average([2, 4, 6]) == 5. Is this expected output correct?
A. No: (2 + 4 + 6) / 3 is 4, so the assert should expect 4 ✓
B. Yes: the AI calculated 5 correctly
Working out the answer by hand shows the AI's expected output is wrong. Fix the test, not the code.

Match the Pairs

assert is_adult(18) == True → An AI-drafted boundary test: you must check by hand that 18 should really count as an adult
assert calc_total([]) == 0 → An edge case the AI may have missed, so you add it yourself: an empty list should give a total of 0
Ask the AI for normal, boundary and invalid tests, not just one kind → Write assert tests for check_age() with normal, boundary and invalid values
Check an AI expected output by hand: 15% of 200 is 30, so this assert is wrong → assert discount(200) == 20
assert get_grade(50) == 'F' # copied from AI, never checked → The expected output was trusted without being checked against the requirement, so the test may be wrong
assert is_valid_age(25) == True # only test written → Only a normal case is tested, so boundary and invalid cases such as -1, 0 and 120 are missing

Key Term

assert
AI can draft assert tests for a module, but you must check each expected output by hand to be sure it is correct. Also add any normal, boundary or invalid cases it missed.

Fill in the Blanks

1. assert add(2, 3) == 5
Hint: Type the keyword that checks a test condition is true.
2. assert add(2, 3) == 5
Hint: Type the operator that compares the actual output with the expected output.
3. # marks run from 0 to 100 assert validMark(0) == True
Hint: Type the lowest valid mark, used as a boundary test value.
4. assert validMark("abc") == False
Hint: Type the Boolean value the function should return for invalid input.
5. assert total([2, 4, 6]) == 12
Hint: Work out the expected output by hand and type that number.

Spot the Error

Question 1
A def is_adult(age):
B return age >= 18
C assert is_adult(18) == False
D assert is_adult(17) == False
Line C — The AI's expected output is wrong. The function uses >= 18, so age 18 is an adult and the boundary test must expect True. Always check each expected value by hand.
Question 2
A def grade(mark):
B if mark => 50:
C return "Pass"
D return "Fail"
E assert grade(50) == "Pass"
Line B — => is not a valid Python comparison operator, so this is a syntax error. It should be >=.
Question 3
A def square(n):
B return n * n
C assert square(3) == 9
D assert square(-2) == -4
Line D — A negative number squared is positive, so the expected output should be 4. An AI tool can get this wrong, so you must check expected outputs by hand.
Question 4
A def add(a, b)
B return a + b
C assert add(2, 3) == 5
D assert add(-1, 1) == 0
Line A — The function header is missing its colon, which is a syntax error. It should be def add(a, b):
Question 5
A def first(items):
B return items[0]
C try:
D first()
E except IndexError:
F print("Test passed")
Line D — The invalid-input test must pass an empty list. Calling first() with no argument raises TypeError, not the IndexError being tested. It should be first([]).

Student with a class code? Join your class →