Skip to content

Instantly share code, notes, and snippets.

@eduardo-matos
Last active February 18, 2026 11:06
Show Gist options
  • Select an option

  • Save eduardo-matos/56120b487ffa53e2c49dc3af8547948b to your computer and use it in GitHub Desktop.

Select an option

Save eduardo-matos/56120b487ffa53e2c49dc3af8547948b to your computer and use it in GitHub Desktop.
Example section for tests in agents.md

Automated Testing Rules

Core Principles

  • Tests protect behavior, not coverage.
  • Prefer high-signal tests.
  • Tests must fail only on real regressions.
  • Test observable behavior, never implementation details.

When Tests Are Required

  • Mandatory for: new features, bug fixes, behavior refactors, non-trivial logic, critical paths.
  • Not required for: trivial getters/setters, wiring, config, generated code.

Strategy & Pyramid

  • Default: unit tests
  • Use integration tests at system boundaries.
  • Use E2E tests only for critical business flows.
  • Prefer integration over heavy mocking.

Design Rules

  • Tests must be independent, deterministic, fast, readable.
  • Structure: Arrange → Act → Assert.
  • Avoid multi-purpose tests.

What To Test

  • Business logic
  • Edge cases
  • Failure paths
  • Boundaries & invariants

Naming

should_<expected_behavior>_when_<condition>

Assertions

  • Assert outputs, state, and side effects.
  • Never assert private methods, internal variables, or call order.

Mocking

  • Mock only: external services, DB, queues, filesystem, time.
  • Never mock: domain logic, value objects, pure functions.
  • Prefer fakes/in-memory adapters.

Test Data

  • Use builders/factories.
  • Keep data minimal and expressive.

Regression & Refactor Safety

  • Every bug fix requires a failing regression test.
  • Add tests before behavior refactors.

AI Rules

  • Never generate shallow coverage tests.
  • Avoid snapshot tests unless requested.
  • Ask for clarification instead of guessing behavior.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment