Videos

Video

Testing and debugging with MIT OpenCourseWare

Use boundary cases and a step-by-step trace to locate the first place a program goes wrong.

Watch on YouTube

This English lecture from MIT 6.0001 covers testing, debugging, exceptions and assertions. Start with test design and locating an error, then return to the remaining topics as you need them.

Predict the result before running

Take a program that counts values at or above 6. Use these cases to check the rule.

Input Expected count What it tests
4, 6, 7, 6, 2 3 Mixed values, repeats and equality
6, 6 2 Values at the threshold
0, 1, 5 0 No matches

Find the first divergence

If the second case fails, inspect the comparison first. If the mixed case fails while equality works, print the value read and cumulative count at each step. Change one thing and rerun all cases, including those that passed before. If the program stops unexpectedly, record the earliest error, the input and the intended output.

Apply the process to your own work

Give binary search a value absent from the list or construct a move that should preserve state in a Bronze simulation. MIT OCW’s official lesson has captions, notes and video.