Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Use the test tool's fixture capabilities (i.e., cleanup/tear-down methods) to perform any required cleanup and reset the test class to a known state instead of using finally blocks.

Use Existing Test Tools and Frameworks

Write Re-Usable Test Code

Tests Before Changes

Before changing, fixing a bug or refactoring existing code, always make sure that tests exist and pass first.

...

A test that requires many mocks usually indicates that the class under test is breaking the Single Responsibility Principle or the Law of Demeter and may need to be refactored.

Comments:

  • Consider making those component tests?
  • Not a hard and fast rule, varies

Dependencies Difficult to Mock

...

This usually indicates that some tests are not properly cleaning up after themselves or are not properly setting up their test prerequisites.

A Lot of Repeated Test Code

Creating Mocks Manually

Anti-Patterns

Sleeps

Brendan Hofmann I could see an argument that everything in this category should be in component tests instead of unit tests.

...