Unit Testing — ภาพรวม
หมวดนี้เป็น language-agnostic (หลักการทั่วไป ไม่ผูกกับภาษาใดภาษาหนึ่ง) ส่วน syntax เฉพาะ ของ Go ดูได้ที่ Go → Testing เนื้อหาเขียนตามโครงเดียวกับหมวด Go (Golang): bilingual ต่อหัวข้อ พร้อมกล่อง "🧠 จำง่ายๆ" และ "🎯 Beyond" ในทุกหัวข้อย่อย
โครงสร้างเนื้อหา
| หัวข้อ | เนื้อหา |
|---|---|
| Test Pyramid | Unit vs Integration vs E2E, Testing Trophy, trade-off ของแต่ละระดับ |
| FIRST Principles | Fast, Independent, Repeatable, Self-validating, Timely |
| Mocking vs Stubbing vs Faking | ความต่างที่แม่นยำของ 3 คำนี้ พร้อมตัวอย่าง |
| Test Doubles & Dependency Boundaries | ทำไมต้อง inject dependency, mock อะไรไม่ mock อะไร |
| Coverage ที่มีความหมาย | ทำไม 100% coverage ไม่พอ, mutation testing |
| Best Practices | Arrange-Act-Assert, naming convention, code review checklist |
| Interview Prep | คำถามสัมภาษณ์ที่พบบ่อยเกี่ยวกับ testing philosophy และ TDD |
ใครควรอ่านหมวดนี้
- Engineer ทุกภาษาที่ต้องการ mental model ที่ถูกต้องเรื่องการเขียนเทสต์ ไม่ใช่แค่ syntax
- คนที่กำลังเตรียมสัมภาษณ์งานที่มักถูกถามเรื่อง testing philosophy/TDD (พบในแทบทุกตำแหน่ง backend/platform engineer)
- คนที่ต้องรีวิวโค้ดของทีมและอยากแยกแยะ "เทสต์ที่ดูดีแต่ไม่มีคุณค่าจริง" ออกจาก "เทสต์ที่มี คุณค่าจริง" ได้
English Summary
This section is language-agnostic; Go-specific testing syntax lives in Go → Testing. It follows the same bilingual, interview-ready template as the Go section: test pyramid → FIRST principles → mocking/ stubbing/faking → test doubles → meaningful coverage → best practices → interview prep.