Exunit Code Review
by @anderskev
Reviews ExUnit test code for proper patterns, boundary mocking with Mox, and test adapter usage. Use when reviewing _test.exs files or test helper configurat...
clawhub install exunit-code-reviewπ About This Skill
name: exunit-code-review description: Reviews ExUnit test code for proper patterns, boundary mocking with Mox, and test adapter usage. Use when reviewing _test.exs files or test helper configurations.
ExUnit Code Review
Quick Reference
| Issue Type | Reference | |------------|-----------| | Async tests, setup, describe, tags | references/exunit-patterns.md | | Behavior-based mocking, expectations | references/mox-boundaries.md | | Bypass, Swoosh, Oban testing | references/test-adapters.md | | What to mock vs real, Ecto sandbox | references/integration-tests.md |
Mock Boundary Philosophy
Mock at external boundaries:
DO NOT mock internal code:
Review Checklist
Test Structure
async: true unless sharing database stateMocking
Test Adapters
Database
Valid Patterns (Do NOT Flag)
Context-Sensitive Rules
| Issue | Flag ONLY IF | |-------|--------------| | Not async | Test actually needs shared state | | Missing mock | External call exists AND no mock/bypass | | Mock internal | Module being mocked is internal code |
Gates (sequence)
Complete in order. Do not emit a finding until the prior step passes for that issue.
1. Evidence from the file β Open the test module (or helper) and tie the claim to concrete lines.
- Pass when: Each prospective finding includes [FILE:LINE] and a one-line factual description of what is on that line (or an adjacent line you name), not a generic style complaint.
2. ExUnit false-positive veto β Check this skillβs Valid Patterns and Context-Sensitive Rules for the case. - Pass when: You can state βnot covered by Do NOT Flag / Flag ONLY IFβ in one sentence, or you drop the finding.
3. Cross-protocol verification β Apply review-verification-protocol (e.g. read full function/block, search usages before βunusedβ claims) to that same finding. - Pass when: At least one protocol check relevant to the claim type is satisfied and would appear in your rationale if challenged.
Before Submitting Findings
Use [FILE:LINE] ISSUE_TITLE per finding after Gates (sequence) and the linked protocol are satisfied.