Testing Strategies and Fixtures
Relevant source files
The following files were used as context for generating this wiki page:
The FLEXT-Core test suite is designed to align with the 1.0.0 modernization pillars, focusing on dispatcher unification, context-first observability, and shared configuration services. The strategy emphasizes module-level guarantees through unit tests, cross-module flows via integration tests, and behavioral contracts via pattern tests.
The suite utilizes a global container and a centralized context bootstrap process to ensure that all components interact correctly within the Dependency Injection (DI) framework. Quality gates are enforced through automated linting, type-checking, and coverage targets.
Sources: tests/README.md:10-15, CONTRIBUTING.md:25-30
Test Suite Architecture
The project organizes tests into three primary layers to isolate concerns and ensure comprehensive coverage.
| Layer | Focus | Key Components Validated |
|---|---|---|
| Unit | Module-level guarantees | Result types, Container, Dispatcher, Context correlation |
| Integration | Cross-module flows | Settings + Container + Dispatcher integration |
| Patterns | Behavioural contracts | CQRS commands, service patterns |
Sources: tests/README.md:18-24
Execution Flow and Quality Gates
The testing workflow follows a tiered approach from local fast checks to full validation gates. Coverage targets are established at a baseline of ≥79%, with a goal of 85% for the 1.0.0 release.
Sources: CONTRIBUTING.md:25-35, tests/README.md:46-50
Fixture Management
Fixtures in FLEXT-Core are designed to bootstrap the FlextContext and the global FlextContainer. Modernized tests are required to rely on FlextSettings and container bootstrap helpers rather than bespoke setup code.
Architectural Validation Fixtures
The suite includes specialized fixtures for validating architectural integrity, such as checking imports and configuration against the pyproject.toml definition.
Service and Application Fixtures
Integration tests utilize service fixtures to simulate end-to-end dispatcher flows. These fixtures exercise context propagation and logging lifecycle events.
FlextContainer: Manages service registration and resolution.FlextContext: Manages request, user, and operation scopes for correlation.enforcement: A pytest plugin fixture (flext_core._fixtures.enforcement) used for runtime rule validation.
Sources: tests/integration/README.md:15-18, pyproject.toml:68-69
Modernization Requirements
New tests must adhere to specific standards to ensure they remain compatible with the 1.0.0 architectural shifts:
- Dispatcher Interaction: All new tests should exercise
FlextDispatcherandFlextContextinteractions. - DI Guarantees: Tests must use
FlextContainerbootstrap helpers to ensure dependency injection remains stable. - Public API Protection: Integration scenarios like
test_wildcard_exports_clean.pyare used to protect the official public API surface exposed via__all__.
Sources: tests/README.md:46-52, tests/integration/README.md:13-15
Architectural Scans and Violations
The architecture validator (tv) produces ScanResult models that identify deviations from architectural rules.
| Field | Description |
|---|---|
passed | Boolean indicating if no violations were found. |
violations | List of Violation objects containing file path and rule ID. |
validator_name | The specific validator method used (e.g., imports, config). |
severity | Violation level (CRITICAL, HIGH, MEDIUM, LOW). |
Sources: tests/integration/test_architecture.py:10-20, tests/integration/test_architecture.py:115-130
Summary
FLEXT-Core employs a structured testing strategy that combines traditional unit and integration testing with architectural enforcement and pattern validation. By leveraging a centralized DI container and context-first observability, the suite ensures that complex cross-module interactions remain reliable as the project modernizes. Key fixtures are centralized in conftest.py and specialized integration files to provide a stable runtime environment for all test tiers.