Testing layers

From jleechanorg/claude-commands · View interactive version

Testing layers is an AI agent skill from the GitHub repository jleechanorg/claude-commands. Select the correct WorldArchitect.AI testing layer and understand its evidence value.

How to use this skill

Skill file

Testing Layers — When to Use Each Layer and How to Decide

Purpose

Directory map, layer-selection principles and evidence value of each test layer for Your Project. Use it when creating tests, reviewing coverage, or judging /es evidence completeness.

Directory Map

| Layer | Directory | Runner | Evidence class |

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

| 1. Unit | $PROJECT_ROOT/tests/ | Use the repository's targeted test runner | Deterministic claims only; no live-service credit |

| 1b. Unit (top-level) | tests/ | Use the repository's targeted test runner | Deterministic claims only; no live-service credit |

| 2. End-to-End | $PROJECT_ROOT/tests/test_end2end/ | Use the repository's targeted test runner and E2E owner | Deterministic composed claims; no live-service credit |

| 3. MCP API | testing_mcp/ | Follow $PROJECT_ROOT/testing_mcp/AGENTS.md | Real server/provider/auth evidence only for claims exercised |

| 4. HTTP API | testing_http/ | Follow current project test instructions | Evidence for the exercised HTTP/server claim |

| 5. Browser | testing_ui/ | Follow $PROJECT_ROOT/testing_ui/CLAUDE.md | Real authenticated browser evidence for the exercised UI claim |

Shared Libraries

| Library | Path | Purpose |

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

| MCP test base | testing_mcp/lib/base_test.py | MCPTestBase — server lifecycle, evidence bundle, provenance |

| MCP campaign utils | testing_mcp/lib/campaign_utils.py | finish_character_creation, process_action, get_campaign_state |

| MCP client | testing_mcp/lib/mcp_client.py | MCP protocol client for tools_call |

| Evidence utils | testing_mcp/lib/__init__.py | capture_provenance, create_evidence_bundle, write_with_checksum |

| Browser test base | testing_ui/lib/browser_test_base.py | BrowserTestBase — Playwright lifecycle, screenshots, video |

| HTTP test config | testing_http/lib/config.py | Server URL config, auth bypass |

Execution Environment


Claim boundary

Follow pr-lifecycle § Change-impact review and test depth and

evidence-standards § Unit proof and claim boundaries: unit proof can establish

self-contained deterministic behavior, not model compliance, auth, persistence

races or browser behavior. /es classification is independent of whether a real

LLM or browser run is necessary. Non-production labels, one file or a small line

count never replace inspecting the actual claim and risk, and the

real-service-only directory rules above stay mandatory.

Decision Principles — Which Layer to Test At

Principle 1: Does the LLM's judgment affect the outcome?

If the behavior under test is deterministic server code that runs the same way whatever the LLM said, a unit test is the correct tier: the LLM is only a trigger, simulated with a dict. Move to a higher layer only when the claim crosses a service or integration boundary the unit test cannot exercise.

Principle 2: Is the boundary being tested at the LLM↔Server interface?

Real LLM tests prove the contract between model output and server consumption works. Mocks assume the shape is correct; real calls prove it.

Principle 3: Is there an integration seam that mocks would hide?

Streaming, parsing, Firestore persistence, DOM rendering — bugs live in the glue, not the logic. If proving "data flows correctly through N layers," real E2E adds value.

Principle 4: Is it a multi-function or multi-file flow of execution?

Spanning multiple functions or files is not by itself a reason for E2E: choose an integration layer only when the path between components is material to the claim. A deterministic composed test outside testing_mcp/ and testing_ui/ may use mocks; keep a unit test when it suffices for the actual behavior.

Select tests from the changed claims and affected boundaries, never a

production-file-count threshold. Exercise the changed path at the lowest

sufficient layer, add an integration test when a unit test would miss a material

seam, and state a concrete reason when no application-level path can exercise a

claim.

Principle 5: Is the cost proportional to the risk?

A Gemini call costs time and tokens; a unit test costs milliseconds. For a 5-line unambiguous dict operation, the risk of a failure that appears only under LLM pressure is near zero.

Principle 6: Can the test pass vacuously?

A real-LLM test that can pass without the guard ever firing (because the LLM ignored the diagnostic prompt) does not test what it claims.


Summary Decision Matrix

| Question | Yes → | No → |

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

| Does LLM judgment affect the outcome? | Layer 3+ (MCP/HTTP/Browser) | Layer 1/2 (Unit/E2E) |

| Testing an LLM↔Server contract? | Layer 3+ | Layer 1/2 |

| Integration seam that mocks hide? | Layer 3+ | Layer 1/2 |

| Risk justifies cost of real LLM call? | Layer 3+ | Layer 1/2 |

| User-visible UI behavior? | Layer 5 (Browser) | Layer 3 or 4 |

| Can it pass vacuously? | Fix the harness first | Proceed |


Evidence Implications by Layer

| Layer | /es Evidence Credit | What It Proves | What It Does NOT Prove |

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

| Unit | Bounded deterministic claims only | Logic correctness in isolation | Integration, real LLM shapes, persistence, UI rendering |

| E2E | Deterministic composed claims only | High-fidelity callstack integration with mock services | Real LLM shapes, browser behavior |

| MCP | ✅ Server + LLM | Real server processes real LLM output correctly | UI rendering, browser behavior |

| HTTP | ⚠️ Server only (no LLM unless explicitly called) | HTTP API contract, auth, response shapes | LLM behavior, UI rendering |

| Browser | Real browser proof for the exercised claim | Observed end-to-end UI behavior | Unexercised flows or services |

Claim-scoped Evidence Artifacts


When Creating a New Test

  1. Identify the claim: What behavior are you proving?
  2. Apply the 6 principles: Is LLM judgment involved? Integration seams? Cost justified?
  3. Choose the lowest sufficient layer for the claim. Don't use Browser when MCP suffices, and don't use MCP when an offline deterministic test proves the bounded claim.
  4. Verify non-vacuous: If using Layer 3+, ensure the test can detect when the target path was NOT exercised.
  5. Emit evidence: Layer 3+ tests must produce /es-compliant bundles. Use MCPTestBase or BrowserTestBase.

References

Resolve the current /end2end-testing, /4layer, /tdd, evidence-standards,

and PR-lifecycle owners through the active command/skill catalog. Resolve the

project root and read its AGENTS.md plus any scoped testing_mcp/AGENTS.md or

testing_ui/CLAUDE.md for directory-specific execution policy.

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.