Ten Commandments for Unit Testing

  1. Refactor SUT to limit LOC required to setup a unit test
  2. Limit a unit test to 10 LOC or less
  3. Engineer tests so that they fail because of business logic and not setup logic
  4. Test behaviors and NOT implementation details
  5. Unit test business logic and NOT integration concerns
  6. Control test dependencies before they control your tests
  7. Provide descriptive test names
  8. Test only one thing per unit test
  9. Engineer tests so that they’re self-contained and can run in complete isolation
  10. Investigate static classes when tests no longer run deterministically

Referenced: Testing with F#

Advertisements