Testing

From liza-mas/liza · View interactive version

Testing is an AI agent skill from the GitHub repository liza-mas/liza. Test Protocol

How to use this skill

Skill file

Tests are the immune system — they reject bugs, not document them.

Test Truth Table

| Code | Test | Interpretation |

|------|------|----------------|

| Working | Green | Good |

| Buggy | Red | Good (bug exposed) |

| Working | Red | Wrong expectations |

| Buggy | Green | DANGEROUS |

| Unknown | Red | STOP — use Analysis Framework below |

ANTI-PATTERN: The most dangerous instinct is to "fix" failing tests by accepting whatever source currently does.

When Tests Fail

Ask for context:

Default heuristic: Tests encode intent; assume the test is correct until evidence suggests otherwise. Source drifts; tests usually don't drift without reason.

Analysis Framework:

  1. Examine both logics independently
  2. Consider system design: method contract, error patterns
  3. Identify sounder logic given context
  4. When uncertain, ask user
  5. Type hints may be wrong — verify actual runtime behavior before trusting signatures

Test Modification

FORBIDDEN without approval:

Allowed: Fresh repro tests capturing current failure (existing tests untouched).

Writing Tests

Quality Standards:

Assertion Strength: Would this test pass for a broken implementation?

If yes (tautology, type-only, existence-only, shape-only), strengthen it. Each negative, exclusion

or isolation test guards one refusal path and must go red without it: the fixture reaches the state

that path decides and breaks only that path, and the oracle is not derived from the input under test.

Mocking Discipline: Test the code, not the scaffolding.

Heavy mock setup suggests you're testing assumptions about dependencies, not behavior.

Mock external boundaries (APIs, DBs, filesystems), not internal logic. A resource holding logic

under test (SQL functions, migrations) is not a boundary: test that logic against the real resource

at its contract, unless the proof environment says otherwise, and keep its callers on fakes.

Pyramid: Prove each behavior once, at the cheapest level that fails when it is wrong. Higher

levels prove composition, not the logic below.

Paired Coverage: For each positive test, consider a negative counterpart.

Happy-path-only is a red flag for complex source.

Coverage Relevance: "Tests pass" ≠ "tests exercise changed code".

For non-trivial changes, verify tests cover modified paths.

Signal Hierarchy: Integration failures > Unit failures for architectural changes.

Green units with red integration = units work but don't compose.

Structure: Prefer GIVEN / WHEN / THEN blocks for readability.

Omit a section when empty; the structure clarifies intent, not ceremony.

Template Principle: Identify one high-quality test file as reference. Match its patterns.

Flaky Tests: Flakiness is a bug, not noise. When encountered: isolate, report, do not retry-until-green. Flakiness masks real failures.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.