Testing Strategy¶
RAG Modulo employs a comprehensive testing strategy with 947+ automated tests organized by speed and scope.
Test Organization¶
Test Categories¶
Tests are organized into four main categories:
- Atomic Tests (Fastest - ~5 seconds)
- Schema and data structure validation
- Pydantic model tests
-
No database required
-
Unit Tests (Fast - ~30 seconds)
- Individual function/class testing
- Mocked dependencies
-
No external services
-
Integration Tests (Medium - ~2 minutes)
- Service interaction tests
- Real database operations
-
Vector database integration
-
End-to-End Tests (Slower - ~5 minutes)
- Full system tests
- API to database workflows
- Complete feature validation
Test Markers¶
Tests use pytest markers for categorization:
@pytest.mark.atomic- Atomic schema tests@pytest.mark.unit- Unit tests@pytest.mark.integration- Integration tests@pytest.mark.e2e- End-to-end tests@pytest.mark.api- API endpoint tests@pytest.mark.performance- Performance benchmarks
Running Tests¶
See Running Tests for detailed commands and usage.
Test Coverage¶
- Minimum Coverage: 60%
- Current Tests: 947+ automated tests
- Coverage Report:
make coverage(generates HTML report)
Testing Best Practices¶
Unit Testing¶
- Mock external dependencies
- Test one component at a time
- Use fixtures for common setup
- Keep tests fast and isolated
Integration Testing¶
- Use real services (Postgres, Milvus)
- Test service interactions
- Validate data persistence
- Clean up test data
End-to-End Testing¶
- Test complete workflows
- Validate API contracts
- Test error handling
- Verify business logic
Test Fixtures¶
Common fixtures are defined in tests/conftest.py:
db_session- Database sessiontest_client- FastAPI test clientsample_user- Mock user for testingsample_collection- Mock collection data
Continuous Integration¶
All tests run in CI/CD pipeline:
- On Every PR: Atomic + Unit tests (~2 min)
- On Push to Main: All tests including integration (~5 min)
See CI/CD Documentation for details.
Test Organization Structure¶
tests/
โโโ unit/ # Unit tests with mocks
โ โโโ services/ # Service layer tests
โ โโโ repository/ # Repository layer tests
โ โโโ schemas/ # Schema validation tests
โโโ integration/ # Integration tests with real services
โโโ api/ # API endpoint tests
โโโ performance/ # Performance benchmarks
Writing New Tests¶
- Determine Test Type
- Atomic: Schema/model validation
- Unit: Single component with mocks
- Integration: Multiple components with real services
-
E2E: Full workflow testing
-
Add Appropriate Markers
-
Use Fixtures
-
Assert Clearly
- Use descriptive assertions
- Test both success and failure cases
- Validate error messages
See Also¶
- Running Tests - How to run tests
- Test Categories - Detailed category descriptions
- Development Workflow - Development process