Codele / How software is built
Testing your code
A test is a small program that checks your program: give it an input, say what you expect, and compare. Then bugs show up before your users find them.
- A test gives the code an input, states the answer you expect, and compares it with what the code got.
- Bugs love edges: the smallest, the biggest, zero, and exactly on the boundary.
- A failing test points at the exact case that is wrong. Fix the code, then run all the tests again.
- Real projects use a test library, but the idea is the same as our small check helper.
Loading the playable lesson…