Coding · Grade 2
Debug and Test Cases
Second graders write test cases (an input and the expected result worked out by hand), run programs to compare actual and expected results, discover that a single passing test can hide a bug, and use a failing test with a trace to find, fix and re-test.
- 3 lessons
- About 70 minutes
- Testing and debugging check: 8 questions
- Ways to answer: fill in the blanks, program with blocks, choose an answer, trace code, highlight a text and match pairs
What learners will discover
- Write a test case: an input and the expected result, worked out by hand.
- Run test cases and decide pass or fail by comparing the actual result with the expected result.
- Use a failing test and a trace to find a bug, fix it, and re-run every test.
Lessons
-
What is a test case? 4 steps2 practiceabout 14 min
-
Pass or fail? 5 steps3 practiceabout 15 min
-
Find, fix, re-test 5 steps3 practiceabout 16 min
-
Testing and debugging check 8 questions at the end
Keep exploring
Games to practice with
- Robot RoutesSnap together arrow, repeat and dance blocks to guide Bolt the robot home.
- Bug DetectiveA robot program almost works. Run it, spot the buggy block, and fix it.
- Mini-Game StudioMake a tiny game with rule blocks, test-play it, and share it once it can be won.
More 2nd grade coding
- 2nd Grade Coding Worksheets10 printable worksheets
Guide for grown-ups
- How to start homeschooling: a step-by-step guide for familiesA guide for parents · 7 min read