Testing Strategy for Helpline & AI Service
This strategy is modeled after the Testing Pyramid, emphasizing a strong foundation of unit tests, supported by integration and end-to-end tests, ensuring the quality, reliability, and performance of helplinev1
and ai_service
.
1. Static Analysis & Code Quality (The Foundation)
Objective: Enforce code style, catch syntax errors, and identify potential security vulnerabilities.
- ai_service (Python)
- Linting: Ruff or Flake8 for PEP 8 compliance and logic errors.
- Type Checking: MyPy to enforce static type hints.
- Security: Bandit to scan for common vulnerabilities. Integration: Pre-commit hooks and mandatory CI pipeline step.
2. Unit Testing
Objective: Verify individual components work correctly in isolation.
ai_service
- Framework: Pytest.
- Models: Test model loading, preprocessing, prediction I/O contracts.
- API Routes: Test endpoint logic, request validation, error handling (mock service layer).
- Services: Test business logic, mocking external dependencies.
- Coverage: Use pytest-cov, target >85%.
helplinev1
- Isolate core logic; mock
ai_service
calls during unit tests.
- Isolate core logic; mock
3. Integration Testing
Objective: Ensure different components or services work together as expected.
Intra-Service (ai_service):
- Test flow from API endpoint → service layer → (mocked) model.
- Use Docker to run tests against service in container.
Inter-Service (helplinev1 ↔ ai_service):
- Verify communication and correct handling of responses.
- Use docker-compose to spin up both services in isolated network.
4. Contract Testing
Objective: Prevent breaking changes between services.
- Method:
- helplinev1 generates a contract file (requests & expected responses).
- Share with ai_service.
- ai_service CI verifies API adheres to contract.
- Tool: Pact.
5. End-to-End (E2E) Testing
Objective: Validate the entire workflow from start to finish.
- Scenarios:
- User call initiated in helplinev1 → audio streamed to ai_service → transcription → summarization → final summary stored and displayed correctly.
- User queries in helplinev1 retrieve data processed by ai_service.
- Tools: Pytest + requests, Playwright, or Cypress (if UI).
6. Performance & Security Testing
Performance Testing:
- Objective: Ensure ai_service handles expected load within acceptable limits.
- Tools: Locust, k6.
- Types: Load, Stress, Soak Testing.
Security Testing:
- Objective: Identify and mitigate vulnerabilities.
- Tools & Techniques:
- Dependency Scanning: pip-audit, Snyk, Dependabot.
- DAST: OWASP ZAP.
CI/CD Pipeline Integration
Stage | Testing Activity | Purpose | Tools |
---|---|---|---|
Pre-Commit | Static Analysis | Catch issues before commit | pre-commit, ruff, mypy, bandit |
On PR/Push | Unit & Integration Tests | Core logic verification | pytest, pytest-cov, Docker |
On PR/Push | Contract Tests | Prevent API breaking changes | Pact |
Post-Deploy (Staging) | E2E Tests | Full system workflow validation | pytest/requests, Playwright |
Scheduled/Manual | Performance Tests | Ensure scalability & stability | Locust, k6 |
Scheduled/Manual | Security Scans | Find vulnerabilities | pip-audit, OWASP ZAP |