Skip to content
Computer Science · Grade 10

Active learning ideas

Logic Errors and Test Cases

Students best recognize logic errors when they actively walk through code with peers rather than reading it alone. Pair and group work forces verbalization of assumptions, exposing hidden flaws that silent desk-checking misses. This topic benefits from collaborative testing because varied perspectives reveal gaps in edge-case coverage that one student’s single perspective overlooks.

Ontario Curriculum ExpectationsCS.HS.P.6CS.HS.P.7
25–45 minPairs → Whole Class4 activities

Activity 01

Case Study Analysis30 min · Pairs

Pair Debug Relay: Logic Error Hunt

Pairs receive a program with a hidden logic error. One partner writes three test cases, the other runs them and predicts outputs. They switch roles to trace discrepancies and propose fixes, then test the revised code together.

Differentiate between syntax errors and logic errors in program execution.

Facilitation TipDuring Pair Debug Relay, provide a visible checklist of common logic error types so partners can systematically scan for each pattern.

What to look forPresent students with a short program containing a subtle logic error. Ask them to write down three specific test cases they would use to uncover the error and predict the output for each. Then, have them explain where the error might be located in the code.

AnalyzeEvaluateCreateDecision-MakingSelf-Management
Generate Complete Lesson

Activity 02

Case Study Analysis45 min · Small Groups

Small Group Test Case Design Challenge

Groups brainstorm and document test cases for a shared algorithm, including boundary values. They exchange sets with another group to run and score for coverage, then discuss gaps and refine their own cases.

Design a comprehensive set of test cases to validate program correctness.

Facilitation TipFor Small Group Test Case Design Challenge, assign each group a unique role (recorder, tester, observer) to ensure equal participation and accountability.

What to look forProvide students with a program snippet and its incorrect output for a given input. Ask them to identify the type of error (syntax or logic) and write one sentence explaining why. Then, have them suggest one modification to the code that would correct the logic.

AnalyzeEvaluateCreateDecision-MakingSelf-Management
Generate Complete Lesson

Activity 03

Gallery Walk40 min · Pairs

Whole Class Output Critique Gallery Walk

Display sample programs with inputs and outputs around the room. Students walk in pairs, noting logic errors on sticky notes. Regroup to vote on common issues and demonstrate fixes using a projector.

Critique a program's output to identify discrepancies caused by logic errors.

Facilitation TipIn the Whole Class Output Critique Gallery Walk, post guiding questions at each station to focus critiques on specific aspects like boundary conditions or loop behavior.

What to look forIn pairs, students exchange a program they have written. One student acts as the 'tester' and designs three test cases for the other student's program, noting expected versus actual outputs. The 'programmer' then reviews the test cases and feedback to identify and fix any logic errors.

UnderstandApplyAnalyzeCreateRelationship SkillsSocial Awareness
Generate Complete Lesson

Activity 04

Case Study Analysis25 min · Individual

Individual Test Suite Builder

Each student creates a test suite for a given function, inputs it into an online tester, and logs pass/fail results. They revise based on failures and share top suites with the class for feedback.

Differentiate between syntax errors and logic errors in program execution.

What to look forPresent students with a short program containing a subtle logic error. Ask them to write down three specific test cases they would use to uncover the error and predict the output for each. Then, have them explain where the error might be located in the code.

AnalyzeEvaluateCreateDecision-MakingSelf-Management
Generate Complete Lesson

A few notes on teaching this unit

Begin by modeling how to trace a loop’s counter with colored pens to visualize off-by-one errors. Avoid starting with abstract definitions; instead, use short, flawed code snippets where the error is not immediately obvious, forcing students to slow down. Research shows that students grasp logic errors better when they experience the frustration of silent failures before learning debugging tools.

By the end of these activities, students will confidently trace code execution, design diverse test cases, and justify corrections for logic errors. They will use precise vocabulary to describe expected versus actual outputs and explain why certain inputs expose specific flaws. Evidence of success includes clear test plans, debated outputs, and revised code that matches expectations across inputs.


Watch Out for These Misconceptions

  • During Pair Debug Relay, watch for students who assume the first output they see is correct and stop testing early.

    In Pair Debug Relay, require partners to list each step of execution and its result before moving to the next line, ensuring they do not skip verification of intermediate values.

  • During Small Group Test Case Design Challenge, watch for students who create multiple tests with the same input range, missing edge cases entirely.

    In Small Group Test Case Design Challenge, provide a card with categories (normal, edge, invalid) and require at least one test case from each category before allowing the group to proceed.

  • During Whole Class Output Critique Gallery Walk, watch for students who accept incorrect outputs as long as the program runs without crashing.

    In Whole Class Output Critique Gallery Walk, post a visible rubric that deducts points for any incorrect output regardless of program termination, forcing students to prioritize correctness over completion.


Methods used in this brief