Test Requirements for AI Code
What This Requires
Define minimum test coverage and test types for AI-generated code: unit tests (80% coverage), integration tests (critical paths), security tests (injection, XSS), and edge case tests (null inputs, boundary values).
Why It Matters
AI-generated code often lacks comprehensive tests. Without testing discipline, subtle bugs and security flaws reach production. Explicit requirements force quality bar.
How To Implement
Set Coverage Minimums
Require 80% line coverage for AI-generated code (vs. 70% for human-written). Enforce via CI/CD gate.
Require Test Types
For each feature, mandate: unit tests (happy path, error handling), integration tests (API contracts, database interactions), security tests (OWASP Top 10 checks), edge case tests (null, max/min values).
Automate Test Generation
Use LLMs to generate initial test cases, then require human review/enhancement. Example prompt: "Generate unit tests for this function covering happy path, edge cases, and errors."
Test Review Checklist
During code review, verify: tests exist and pass, coverage meets minimum, tests are meaningful (not just assertions that always pass), security scenarios covered.
Evidence & Audit
- Test requirements policy document
- CI/CD coverage reports showing compliance with minimums
- Sample test suites for AI-generated code
- Code review checklists including test verification
- Training materials on test requirements