ai-generated-ut-code-review
21
总安装量
11
周安装量
#17514
全站排名
安装命令
npx skills add https://github.com/openharmonyinsight/openharmony-skills --skill ai-generated-ut-code-review
Agent 安装分布
opencode
10
amp
6
kimi-cli
6
github-copilot
6
gemini-cli
6
Skill 文档
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 xRisk: Low/Medium/High/Blocker â ç®è¿°åå ï¼1 è¡ï¼Must-fix:- [å¨ä½ + è¯æ®]
- [å¨ä½ + è¯æ®]
Key Evidence:- å¼ç¨å ·ä½æµè¯ç¨ä¾åæè¦ççæ¥åæè¦ï¼1-2 æ¡ï¼
Notes:- æå°ä¿®å¤å»ºè®®ææ¿ä»£æ¹æ¡ï¼1-2 è¡ï¼
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.