Stage 5 · Lesson 6 of 10
Unit tests and edge cases
A calls one small piece of code with known inputs and checks the output automatically. So you know within seconds whether a change broke something. Each test has the same shape: arrange the inputs, act by calling the , then assert (check) the result.
Test the normal case first, then the : an empty list, one item, zero, negative numbers, the largest value and invalid input. Most bugs live at these edges. Use your language's standard , such as pytest, Vitest, JUnit, GoogleTest or xUnit, and run the tests from the terminal.
Tests only work on code that returns values instead of printing them, which is why came first.
A question to check yourself, an AI practice session and 3 cheat sheet entries come when you add the roadmap to your account. Add it
Resources for this stage
Start with· follow one of these
- CoursePaidGrokking SOLID Design Principles
Design Gurus · Beginner · $50 one-time
Five principles with code examples, including when applying them makes code worse
- GuideFreeRefactoring.Guru: Code Smells and Refactoring
Refactoring.Guru · Beginner
Free catalogue of code smells and the small refactorings that fix each one