DOCS / GUIDES

Testing: do not count your chickens before they hatch

Write tests that tell you the truth before production does.

Beginner12 min read
Before you beginYou need the cluck CLI, a Pollosoft account, and a coop to work in. No prior experience required. Curiosity and a mild fondness for chickens are helpful.

Overview

Write tests that tell you the truth before production does. The whole thing takes about 12 minutes, and the commands below are the ones you will use along the way.

$ cluck test
$ cluck test --watch
$ cluck test --coverage

Steps

  1. Test behavior, not implementation. A test should survive a refactor. If it breaks when you rename a private function, it is testing the wrong thing.
  2. Keep tests fast. A slow suite does not get run. Aim for under two minutes, and parallelize the rest.
  3. Fix flaky tests. Quarantine flaky tests immediately and fix them within a week. Candle can help find them.
  4. Test in production, carefully. Use canary releases and feature flags. Test with real traffic, but a small, forgiving flock.

Keep going

Stuck? Check the error codes, the FAQ, or the glossary.