This change series allows you to make untestable code become easy to test. This will not prevent any bugs, but it will speed up release validation, find bugs earlier, and reduce the cost of sharing code between teams.

Habit: Healthy Unit Tests 1 — Readable Tests

Organization ROI: Communication between developers and product owners become easier.

Engineer ROI: Instantly know why each test exists and what code to change when requirements change.

Habit: Healthy Unit Tests 2 — Stop Testing Internals

Organization ROI: Tests tell you where you will pay costs on future stories.

Engineer ROI: Refactoring never requires updating tests.

Habit: Healthy Unit Tests 3 — Test Long Methods

Organization ROI: Begin automatically verifying your most important chunks of code. Reduce the cost of future changes.

Engineer ROI: Test responsibilities independently, even when they are in the same method.

Habit: Healthy Unit Tests 4 — Decoupling and Microtesting

Organization ROI: Tests speed up, have fewer false positives, and cover more of the code.

Engineer ROI: Every test passes 100% of the time when the code is right, fails 100% of the time when it is wrong, and executes in <1ms, in parallel with any other tests.

Habit: Healthy Unit Tests 5 — No Squeezable Tests

Organization ROI: Each test verifies something important, without locking in details you might want to change later.

Engineer ROI: Start with any high-level test and squeeze it down to its essence.

Habit: No More Mocking

Organization ROI: Tests tell you where stories will cause non-local interaction bugs.

Engineer ROI: When the product is broken a test will fail. No longer have 2 parts of the code have different expectations.

Habit: No Emergent Behaviors

Organization ROI: Reduce regression bugs and surprising interactions. New features no longer destabilize existing capabilities.

Engineer ROI: Test behaviors that arise from functionality split into different units.