AI UT Code Review
Overview
Review AI-generated unit tests for effectiveness, coverage, assertions, negative cases, determinism, and maintainability. Output a 0-10 score, a risk level, and a must-fix checklist. Overall line coverage must be >= 80%; otherwise risk is at least High.
When to Use
- AI-generated UT/test code review or quality evaluation
- Need scoring, risk level, or must-fix checklist
- Questions about coverage or assertion validity
Workflow
- Confirm tests target the intended business code and key paths.
- Check overall line coverage (>= 80% required).
- Inspect assertions for behavioral validity; flag missing/ineffective assertions.
- Verify negative/edge cases and determinism (no env/time dependency).
- Score by rubric, assign risk, list must-fix items with evidence.
Scoring (0-10)
Each dimension 0-2 points. Sum = total score.
| Dimension |
0 |
1 |
2 |
| Coverage |
< 80% |
80%+ but shallow |
80%+ and meaningful |
| Assertion Quality |
No/invalid assertions |
Some weak assertions |
Behavior-anchored assertions |
| Negative & Edge |
Missing |
Partial |
Comprehensive |
| Data & Isolation |
Flaky/env-dependent |
Mixed |
Deterministic, isolated |
| Maintainability |
Hard to read/modify |
Mixed quality |
Clear structure & naming |
Risk Levels
- Blocker: Coverage < 80% AND key paths untested, or tests have no meaningful assertions
- High: Coverage < 80% OR assertions largely ineffective
- Medium: Coverage OK but weak edge cases or fragile design
- Low: Minor improvements
Must-Fix Checklist
- Overall line coverage >= 80%
- Each test has at least one behavior-relevant assertion
- Negative/exception cases exist for core logic
- Tests are deterministic and repeatable
AI-Generated Test Pitfalls (Check Explicitly)
- No assertions or assertions unrelated to behavior (e.g., only not-null)
- Over-mocking hides real behavior
- Only happy-path coverage
- Tests depend on time/network/env
- Missing verification of side effects
Output Format (Required, Semi-fixed)
Score: x/10 — Coverage x, Assertion Quality x, Negative & Edge x, Data & Isolation x, Maintainability x
Risk: Low/Medium/High/Blocker — 简述原因(1 行)
Must-fix:
Key Evidence:
Notes:
Rules:
- 覆盖率 < 80% 风险至少 High,并必须列入
Must-fix
- 无断言/无效断言直接提升风险级别,必须列入
Must-fix
- 至少 2 条证据;证据不足需说明并降分
Common Mistakes
- 仅报告覆盖率,不评价断言有效性
- 把日志输出当成断言
- 忽略失败路径/异常路径
Example (Concise)
Score: 5/10 (Coverage 1, Assertion 0, Negative 1, Data 2, Maintainability 1)
Risk: High
Must-fix:
- Tests for
parseConfig() contain no behavior assertions (only logs)
- No negative cases for malformed input
Key Evidence:
parseConfig() tests only assert no crash
- Coverage report shows 62% lines
Notes:
- Add assertions on outputs and side effects; add invalid input tests.
1---2name: ai-generated-ut-code-review3description: Use when reviewing or scoring AI-generated unit tests/UT code, especially when coverage, assertion effectiveness, or test quality is in question and a numeric score, risk level, or must-fix checklist is needed4---56# AI UT Code Review78## Overview9Review AI-generated unit tests for effectiveness, coverage, assertions, negative cases, determinism, and maintainability. Output a 0-10 score, a risk level, and a must-fix checklist. Overall line coverage **must be >= 80%**; otherwise risk is at least High.1011## When to Use12- AI-generated UT/test code review or quality evaluation13- Need scoring, risk level, or must-fix checklist14- Questions about coverage or assertion validity1516## Workflow171. Confirm tests target the intended business code and key paths.182. Check overall line coverage (>= 80% required).193. Inspect assertions for behavioral validity; flag missing/ineffective assertions.204. Verify negative/edge cases and determinism (no env/time dependency).215. Score by rubric, assign risk, list must-fix items with evidence.2223## Scoring (0-10)24Each dimension 0-2 points. Sum = total score.2526| Dimension | 0 | 1 | 2 |27| --- | --- | --- | --- |28| Coverage | < 80% | 80%+ but shallow | 80%+ and meaningful |29| Assertion Quality | No/invalid assertions | Some weak assertions | Behavior-anchored assertions |30| Negative & Edge | Missing | Partial | Comprehensive |31| Data & Isolation | Flaky/env-dependent | Mixed | Deterministic, isolated |32| Maintainability | Hard to read/modify | Mixed quality | Clear structure & naming |3334## Risk Levels35- **Blocker**: Coverage < 80% AND key paths untested, or tests have no meaningful assertions36- **High**: Coverage < 80% OR assertions largely ineffective37- **Medium**: Coverage OK but weak edge cases or fragile design38- **Low**: Minor improvements3940## Must-Fix Checklist41- Overall line coverage >= 80%42- Each test has at least one behavior-relevant assertion43- Negative/exception cases exist for core logic44- Tests are deterministic and repeatable4546## AI-Generated Test Pitfalls (Check Explicitly)47- No assertions or assertions unrelated to behavior (e.g., only not-null)48- Over-mocking hides real behavior49- Only happy-path coverage50- Tests depend on time/network/env51- Missing verification of side effects5253## Output Format (Required, Semi-fixed)54- `Score`: x/10 — Coverage x, Assertion Quality x, Negative & Edge x, Data & Isolation x, Maintainability x55- `Risk`: Low/Medium/High/Blocker — 简述原因(1 行)56- `Must-fix`:57 - [动作 + 证据]58 - [动作 + 证据]59- `Key Evidence`:60 - 引用具体测试用例名或覆盖率报告摘要(1-2 条)61- `Notes`:62 - 最小修复建议或替代方案(1-2 行)6364**Rules:**65- 覆盖率 < 80% 风险至少 High,并必须列入 `Must-fix`66- 无断言/无效断言直接提升风险级别,必须列入 `Must-fix`67- 至少 2 条证据;证据不足需说明并降分6869## Common Mistakes70- 仅报告覆盖率,不评价断言有效性71- 把日志输出当成断言72- 忽略失败路径/异常路径7374## Example (Concise)75Score: 5/10 (Coverage 1, Assertion 0, Negative 1, Data 2, Maintainability 1)76Risk: High77Must-fix:78- Tests for `parseConfig()` contain no behavior assertions (only logs)79- No negative cases for malformed input80Key Evidence:81- `parseConfig()` tests only assert no crash82- Coverage report shows 62% lines83Notes:84- Add assertions on outputs and side effects; add invalid input tests.