/note/tech

xUnit Test Patternsから学ぶ12個のユニットテストの原則

本エントリは、xUnit Test Patterns: Refactoring Test Codeという書籍の「Chapter5 Principles of Test Automation」の内容をベースに、12個のユニットテスト原則についてまとめていきます。この書籍は、2007年に販売されたものですが、今でも十分役に立つユニットテストに関する原則を伝えています。

  • Write the Tests First
  • Design for Testability
  • Use the Front Door First
  • Communicate Intent
  • Don't Modify the SUT
  • Keep Tests Independent
  • Isolate the SUT
  • Minimize Test Overlap
  • Minimize Untestable Code
  • Keep Test Logic Out of Production
  • Verify One Condition per Test
  • Test Concerns Separately