Search⌘ K
AI Features

Defining a Good Test

Explore how to define good unit tests using test-driven development principles. Understand the importance of the FIRST principles: Fast, Isolated, Repeatable, Self-verifying, and Timely. Learn why writing one assert per test enhances clarity and reliability. Gain insights on test isolation and scope to create maintainable, effective tests that provide immediate feedback during development.

Like all code, unit test code can be written in better or worse ways. We’ve seen how AAA helps us structure a test correctly and how accurate, descriptive names tell the story of what we intend our code to do. The most useful tests also follow the FIRST principles and use one assert per test.

Applying the FIRST principles

These are a set of five principles that make tests more effective:

  • Fast

  • Isolated

  • Repeatable ...

...