Testing Strategy¶
Testing Pyramid¶
Tests are organised in a pyramid structure with more unit tests than integration tests:
graph TD
A[Integration Tests] --> B[Application Unit Tests]
B --> C[Domain Unit Tests]
style C fill:#e8f5e9
style B fill:#fff3e0
style A fill:#ffebee
Test Characteristics:
| Test Type | Speed | Quantity | Dependencies | Purpose |
|---|---|---|---|---|
| Domain Unit Tests | Fastest | Most | None (pure domain) | Test value objects and entities |
| Application Unit Tests | Fast | Medium | Mocked repositories | Test handlers and validators |
| Integration Tests | Slower | Fewest | Real database (Docker) | Test full API → Database flow |
BE¶
Integration Test Setup¶
- Uses Testcontainers for real MySQL database in Docker
- All tests share a single container for performance (marked with
[Collection(nameof(IntegrationTestCollection))]) - Each test gets a clean database automatically
- Inherits from
BaseIntegrationTestfor common setup