Cargo Cult Testing
ELI5 — The Vibe Check
Cargo cult testing is writing tests that look like real tests but don't actually test anything meaningful — checking that true equals true, mocking everything so the test only tests the mocks, or asserting that a function was called without checking if it did the right thing. The test suite is green, the coverage number is high, and the code is still broken.
Real Talk
Cargo cult testing is an anti-pattern where tests mimic the form of good tests without providing value. Common patterns: testing implementation details instead of behavior, over-mocking that makes tests tautological, snapshot tests that always get updated without review, and tests that pass regardless of code correctness. Effective tests verify behavior, catch regressions, and fail when code breaks.
When You'll Hear This
"These tests mock the entire database and then test... that the mock returns what it was told to return. Cargo cult testing." / "100% coverage means nothing if it's cargo cult testing."
Related Terms
Code Coverage
Code coverage is the report card for your tests. It shows you a map of your code and highlights which lines got tested (green) and which didn't (red).
Integration Test
If a unit test checks one LEGO brick, an integration test checks that two bricks actually snap together correctly.
Mock
A mock is a fake version of something your code talks to.
TDD (TDD)
TDD means you write the test BEFORE you write the code.
Unit Test
A unit test is like checking that one single LEGO brick isn't broken before you use it in your big castle.