Automated test (โค้ดที่ทดสอบโค้ด) ให้ประโยชน์ที่สำคัญ — จับ bug ช่วยให้เปลี่ยนแปลงได้อย่างมั่นใจ ทำหน้าที่เป็นเอกสารประกอบ และสนับสนุนการส่งมอบที่รวดเร็วและเชื่อถือได้ การเข้าใจว่าทำไมจึงควรเขียนมันช่วยสร้างแรงจูงใจให้กับวินัยนี้ และเป็นพื้นฐานของการพัฒนาที่มีคุณภาพ
ประโยชน์หลักของ automated test
✓ CATCH BUGS EARLY — find defects during development, before users (cheaper to fix)
✓ PREVENT REGRESSIONS — tests catch when a change breaks existing functionality
(run them after every change → safety net)
✓ CONFIDENCE TO CHANGE — refactor and add features knowing tests will catch breakage
(without tests, changes are scary; with tests, you change freely)
✓ DOCUMENTATION — tests show how code is meant to be used and what it should do
✓ FAST FEEDBACK — automated tests run in seconds (vs slow, error-prone manual testing)
✓ Enable CI/CD — automated tests are the foundation of automated, safe delivery
