DRN.Test.Integration Overview
Integration testing suite using Testcontainers, WebApplicationFactory, and xUnit.
Core Concepts
- •DrnTestContext: Primary test fixture.
- •ContainerContext: Manages docker containers (Postgres, RabbitMQ, etc.).
- •ApplicationContext: Manages
WebApplicationFactoryfor E2E tests (automatically setsDrnTestContextEnabledandTemporaryApplicationflags).
Skill Selection
API & End-to-End Testing
Use when testing Controllers/Endpoints.
- •Uses
CreateClientAsync(Auto-setup). - •Mocks external HTTP calls via
Flurl. - •Validates full request pipeline (middleware, auth, etc.).
Database Component Testing
Use when testing internal components (Repositories, Services) in isolation.
- •Manual Setup Required: Must call
AddServicesandApplyMigrationsAsync. - •Best for checking complex SQL, transactions, or concurrency logic without web overhead.
Project Structure
text
DRN.Test.Integration/ ├── Tests/ │ ├── Sample/ │ │ ├── Controller/ # API Tests (End-to-End) │ │ └── Infra/ # DB/Component Tests (Isolated) ├── TestStartupJob.cs # One-time global setup (passwords, auth) └── Usings.cs # Global Usings (xUnit, FluentAssertions)