← ClaudeAtlas

clean-testslisted

Use when writing, fixing, editing, or refactoring Python tests. Enforces Clean Code principles—fast tests, boundary coverage, one assert per test.
phanijapps/memex · ★ 0 · AI & Automation · score 75
Install: claude install-skill phanijapps/memex
# Clean Tests ## T1: Insufficient Tests Test everything that could possibly break. Use coverage tools as a guide, not a goal. ```python # Bad - only tests happy path def test_divide(): assert divide(10, 2) == 5 # Good - tests edge cases too def test_divide_normal(): assert divide(10, 2) == 5 def test_divide_by_zero(): with pytest.raises(ZeroDivisionError): divide(10, 0) def test_divide_negative(): assert divide(-10, 2) == -5 ``` ## T2: Use a Coverage Tool Coverage tools report gaps in your testing strategy. Don't ignore them. ```bash # Run with coverage pytest --cov=myproject --cov-report=term-missing # Aim for meaningful coverage, not 100% ``` ## T3: Don't Skip Trivial Tests Trivial tests document behavior and catch regressions. They're worth more than their cost. ```python # Worth having - documents expected behavior def test_user_default_role(): user = User(name="Alice") assert user.role == "member" ``` ## T4: An Ignored Test Is a Question About an Ambiguity Don't use `@pytest.mark.skip` to hide problems. Either fix the test or delete it. ```python # Bad - hiding a problem @pytest.mark.skip(reason="flaky, fix later") def test_async_operation(): ... # Good - either fix it or document why it's skipped @pytest.mark.skip(reason="Requires Redis, see CONTRIBUTING.md for setup") def test_cache_invalidation(): ... ``` ## T5: Test Boundary Conditions Bugs congregate at boundaries. Test them explicitly. ```python def test_p