Process · Testing
Kiến trúc test tích hợp cho Web API
Kiến trúc test tích hợp cho Web API
Test xUnit gọi WebApplicationFactory (chạy Program.cs thật) bằng HttpClient. Factory chạy migration thật lên PostgreSQL trong Testcontainers và áp ConfigureTestServices để đè FakeEmailService và TestAuthHandler sau Program.cs. Respawn reset cơ sở dữ liệu trước mỗi test.
ConfigureTestServices
đè sau Program.cs
HTTPCLIENT
MIGRATION THẬT
RESET TRƯỚC MỖI TEST
Test xUnit
WebApplicationFactory
Program.cs thật
FakeEmailService
TestAuthHandler
PostgreSQL
Testcontainers
Respawn
CHÚ GIẢI
Chạy Program.cs thật
Cơ sở dữ liệu thật
Dịch vụ bị thay thế
Hướng gọi
© tiennhm