โ Code Review learning pathCode Review ยท Module 6 of 8
Reviewing tests
Tests are code too.
๐ Key ideas
- Every bug fix should come with a test that fails without the fix.
- New behaviour needs tests for the normal case, edge cases and error cases.
- Good tests are readable: clear names, simple setup and one idea per test.
- Tests must be reliable; a test that passes or fails at random (flaky) erodes trust.
- Coverage numbers help but do not prove the right things are checked.
๐ก Real-life example: A test is a guard who remembers: once a bug is fixed and a test is added, the guard stops that bug from sneaking back in later.
Unit testTest of one small piece of code in isolation
Flaky testTest that sometimes passes and sometimes fails without code changes
CoverageShare of code lines run by tests
AssertionCheck inside a test that a result is as expected