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.
Feature tests exercise the full request/response cycle including routes, middleware, authentication, validation, and database—catching realistic bugs users experience.
- Unit tests isolate individual components (Services, Model methods) without the HTTP layer.
- Example feature test: testing full login flow end-to-end with real DB.
- Example unit test: testing password hashing logic in isolation.
- The Laravel community generally favors feature tests for their higher ROI in typical apps, though the right balance depends on the project.
- Unit tests suit complex business logic (pricing engines, algorithms).
- Pest emphasizes feature tests as the primary testing strategy.