principle-test-behavior-not-implementation
Apply when writing or reviewing tests. Verify observable outcomes and identify assertions that cannot detect a relevant defect.
- License 许可
- MIT
- 最近更新
- 2026-09-28
- Stars
- ★ 1
- Forks
- 0
01 前言 Front Matter
- name
- principle-test-behavior-not-implementation
- description
- Apply when writing or reviewing tests. Verify observable outcomes and identify assertions that cannot detect a relevant defect.
02 资源文件 1
- 参考文档agents/openai.yaml293 B
03 SKILL.md 正文
Test behavior, not implementation
Call the code the way its users do and assert the result they observe against an independently chosen expected value.
Before keeping a test, name a relevant defect that would make it fail. Consider a missing implementation, incorrect output, or forbidden side effect. If the test still passes, improve its assertion or remove it when no required contract depends on it.
Inspect these patterns:
- Weak assertions that establish only existence or a broad type instead of the expected result.
- Mock-call counts without the payload or resulting state that matters to the caller.
- Expected values computed by the same implementation being tested.
- Constant pins that repeat an incidental implementation choice.
- Fixtures that assert only their own setup without exercising the subject.
Assertion names alone do not establish whether a test is weak. An absence can be the required behavior, such as no write after rejected input. Pair it with a valid-input case when that distinguishes a working guard from a missing implementation.
For example, call slugify("Hello, World!") and compare its output with "hello-world". For a mock, check the meaningful payload or resulting state. For configuration, test the mechanism that consumes it.
Preserve required provenance pins, compatibility contracts, safety gates, table relations, and compile-time checks. This principle does not authorize removing a maintenance requirement because it checks data or instructions.
04 同仓库更多 Skills
why
Use for 'why does X work this way', 'why we picked Y', design rationale, regressions, postmortems, or data-backed thresholds. Discovers available MCPs and queries each evidence category (source control, issue tracker, long-form docs, real-time chat, infrastructure observability, error tracking, product analytics warehouse) in parallel, then returns a cited read on decisions and tradeoffs. Use how for runtime behavior.
unslop
Cut AI tells from any writing. Must always apply.
typescript-best-practices
TypeScript best practices. Use when reading or editing any .ts or .tsx file.
technical-writing
Layered technical-writing standard: Diátaxis structure, Google developer style sentences, STE instruction rules, Global English syntax. Use for $technical-writing or when writing or reviewing docs, RFCs, readmes, PR descriptions, or commit messages.
teach
Explain a body of work plainly so a person actually understands it. Runs the `how` and `why` skills and weaves what they find into one clear explanation. Use for 'teach me this', 'help me really understand X', 'explain this change or subsystem to me'.
tdd
Use only when the user explicitly asks for TDD, a failing test, or a regression test, OR when the bug has an obvious cheap local test target. Skip when the test path is unclear, expensive, integration-heavy, or not requested.