Sự khác biệt giữa Feature tests và Unit tests trong Laravel là gì?
Feature tests kiểm tra toàn bộ chu trình request/response bao gồm route, middleware, authentication, validation và database—bắt bug thực tế người dùng gặp.
Unit tests cô lập từng component (Service, Model method) mà không có HTTP layer.
Ví dụ feature test: kiểm tra flow đăng nhập end-to-end với DB thực.
Ví dụ unit test: kiểm tra logic hash password trong isolation.
Community Laravel thường ưu tiên feature test vì mang lại ROI cao hơn cho Laravel app thông thường, nhưng tỷ lệ tối ưu tùy thuộc vào từng dự án.
Unit test phù hợp cho business logic phức tạp (tính giá, thuật toán).
Pest nhấn mạnh feature test là chiến lược test chính.
Xem toàn bộ Laravel cùng filter theo level & chủ đề con.