Test quality
Apply test quality principles when generating or reviewing test code. Enforces Arrange-Act-Assert structure, one behavior per test, assertion quality, test isolation, meaningful naming, and test data management. Use when writing tests, reviewing test code, or when the user mentions 'write tests', 'test this', 'test quality', 'test review', 'improve tests', or 'test structure'. This skill governs the craft of writing individual test cases -- not what to test (that is driven by the code being implemented) but how to write tests that are reliable, readable, and maintainable.From its SKILL.md
npx -y skills add techygarg/lattice --skill test-qualityAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
SKILL.md
6.8 KB, ~1.4k tokens by cl100k_base, as published. Nobody here has run it
Test Quality
Config Resolution
Skill support project custom. Order:
- Look
.lattice/config.yamlin repo root - If find, check
paths.test_qualityfor custom doc path - If custom path exist, read doc & check YAML frontmatter for
mode:mode: override(or no mode): Custom doc take full control. Use instead default. Must be complete -- is only reference.mode: overlay: Read./references/defaults.mdfirst, then apply custom doc on top. Custom sections replace match sections (by heading). New sections add after.
- If no config/path/file, read
./references/defaults.md - Language adaptation: If
paths.language_idiomsexist in config, read "Testing Patterns" section and adapt §5 (Test Naming), §4 (Test Isolation), §6 (Test Data Builders) to language test framework idioms. Language idioms take precedence over pseudocode defaults.
Self-Validation Checklist
STOP after gen each test. Check ALL before continue. If fail, fix. If ambiguous (see Ambiguity Signals), flag -- show options & reasoning.
- AAA STRUCTURE: arrange, act, assert separate w/ blank lines? Any logic (if/loop/try) in arrange or assert?
- SINGLE BEHAVIOR: Test verify one behavior per loaded doc (default: one behavior per test, name need "and" = split)?
- ASSERTION QUALITY: Assert observable behavior, not implementation? Specific enough catch regression?
- ISOLATION: Test depend other test output/effects? All mutable state per-test?
- TEST NAME: Name follow team convention per loaded doc (default: describe behavior, not method)? Failure message clear?
- TEST DATA: Complex arrange uses builders/factories? Magic values → named constants? (Inline literals fine for trivial tests.)
- MOCK BOUNDARIES: Mock per loaded doc (default: only at arch boundaries — I/O, external — not internal collab)?
- TEST CODE AS FIRST-CLASS: Structured like production code? Shared constants at top, helpers extracted, no dead code, clear file organization?
Project-specific checks: if loaded doc contains a validation checklist section, apply those after base checklist.
Active Anti-Pattern Scan
After checklist, scan these. If find, fix before present.
- Test-per-Method: One test per method regardless behaviors → One test per scenario, named for behavior
- Assertion Roulette: Multiple unrelated asserts; unclear which broke → Split to one behavior per test
- Shared Mutable State: Pass alone, fail together → Isolate state; per-test setup; no static mutable
- Testing Implementation Details: Break on refactor w/ same behavior; mock call counts → Assert observable behavior, not method calls
- Mystery Guest: Depend external file/db/env var not visible → Inline data or use builders; all preconditions visible
- Slow Tests by Default: Unit suite take minutes; hit db/network/fs → Mock/fake I/O; use in-memory
- Conditional Test Logic: Test have if/loop/try -- test need own tests → Remove logic; use parameterized; let asserts fail natural
- Copy-Paste Tests: Near-identical w/ small changes → Extract shared setup to builders; use parameterized
Class-Level Review
Fire when: (1) completing all tests for a class — new or existing. (2) adding or editing any test in an existing class.
STOP before present. Per-test checks verify individual quality. This review verifies the test suite covers the class contract.
Full review (new class or significant additions)
- Behavior inventory — list every public method/behavior in class under test. If class not available, ask user to enumerate.
- Coverage matrix — map each test → behavior it covers. Behaviors with zero tests → blocking. Do not present until user addresses gap or explicitly accepts it.
- Error path check — scan class under test for: explicit throws, conditional error branches, edge guards. For each found: does a test exercise this path? If not → flag by name. Zero-coverage error paths are blocking unless user explicitly accepts.
- Behavioral duplication — compare "then" clauses across all tests. Same observable outcome regardless of structural differences → flag as likely duplication. Name both tests.
- Balance signal — any behavior with tests but none covering a failure or edge case → surface as question, not hard failure: "
deleteUserhas 1 test (happy path only) — does it have error cases?"
Edit-scoped review (adding or changing one test in existing class)
Run steps 3–5 only, scoped to the changed test:
- Does this test duplicate the observable outcome of any existing test?
- Does it cover a behavior or error path not previously covered?
Ambiguity Signals
Multiple valid outcomes. Present options, not choose silent.
- Unit vs Integration: Service coordinate components -- test isolate (mock) or real collab? Depend coupling & what verify.
- Mock Depth: Mock direct depend or let call through? Over-mock test implementation; under-mock create slow/flaky.
- Test Granularity: One test multi asserts vs multi tests one assert? When asserts verify facets same behavior, group ok.
Test Code as First-Class Code
Treat test files like production classes:
- Shared constants and boundary values at top of file (named, not magic)
- Shared builders/factories extracted to helpers -- not copy-pasted per test
- Setup methods or fixtures for repeated arrange patterns
- Logical grouping: related behaviors together (by feature, by scenario type)
- Dead tests removed, not commented out
- Refactoring applies: extract method when arrange is long, rename when intent unclear, move shared setup when duplicated
Refactoring opportunities to surface proactively:
- Multiple tests repeat same arrange → extract to builder or shared fixture
- Same assertion pattern across tests → extract custom assertion helper
- Test file grows beyond ~300 lines → split by behavior group
- Constants scattered inline → collect at top with descriptive names
- Deeply nested test structures → flatten with clear naming
See ./references/defaults.md for AAA structure examples, assertion patterns, isolation techniques, naming conventions, test data builder patterns, and pyramid distribution guidance.
What ships with it: 1 file
16.7 KB alongside SKILL.md
references/
- defaults.md16.7 KB
Gives 0 of the 12 instructions most docs writing skills give in ~1.4k tokens
Counted across 1,951 of the 3,904 authors here whose files we hold, read 2026-09-06
- Use third-person for skill descriptionsin 54 of 1951, across 35 files
- Start descriptions with Use whenin 43 of 1951, across 29 files
- Run baseline scenarios before writing any skillin 40 of 1951, across 26 files
- Use active voicein 40 of 1951, across 36 files
- Map file responsibilities before defining tasksin 36 of 1951, across 29 files
- Use checkbox syntax for tracking stepsin 35 of 1951, across 27 files
- Ask one question at a timein 35 of 1951
- Offer execution options after saving the planin 33 of 1951, across 24 files
- Include complete code in every stepin 33 of 1951, across 27 files
- Design units with clear boundaries and interfacesin 31 of 1951, across 23 files
- Announce the skill usage at the startin 30 of 1951
- Verify agent compliance after adding the skillin 29 of 1951, across 17 files
Said here and by no other author read
- isolate tests from mutable state
- use builders or factories for complex test data
- stop and validate each test against checklist
- map tests to class behaviors for coverage
- flag ambiguous testing scenarios to the user
- extract shared setup to builders or fixtures
Grouped from the skills themselves: near-identical wordings counted once, and counted by distinct author, so one author publishing three of these counts once. Length counted with cl100k_base; the agent that loads this file may tokenize it differently.