Defining a Good Test

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

  • Self-verifying

  • Timely

Get hands-on with 1400+ tech skills courses.