‹ 首页

bdd-with-approvals

@lexler · 收录于 昨天 · 上游提交 1 周前

Scannable BDD tests written in domain language. Use when doing BDD.

适合你,如果你在项目中实践行为驱动开发

/ 通过 npx 安装 校验哈希
npx oh-my-skill add lexler/skill-factory/bdd-with-approvals
/ 通过 bash 安装
curl -fsSL https://oh-my-skill.com/install.sh | bash -s -- lexler/skill-factory/bdd-with-approvals
/ 已经装过?验证本机副本,不用重装
npx oh-my-skill verify lexler/skill-factory/bdd-with-approvals
安装目标可用 --agent / --scope 或 --to 明确指定;省略时只会在唯一已存在的 agent 目录上自动选择,零命中或多命中会停止并提示。content_hash 缺失或不一致均拒装。
223GitHub stars
~591最小装载
~1.8K含声明引用
~1.8K文本包总量
索引托管

怎么用

商店整理自技能原文 · 版本 2eae60e · 表述以原文为准
它做什么

安装后,Claude 会引导你在实现代码之前,用领域语言编写可执行的规范(fixture 文件)。这些规范既描述预期行为,也是测试用例,你一眼就能判断是否正确。

什么时候触发

当你在做行为驱动开发(BDD),需要先写可执行规范,再用代码实现时触发。

装好后可以这样说
Claude 会生成 fixture 文件。
输出可扫描的输入输出模板。
Claude 提供格式化建议。
技能原文 SKILL.md作者撰写 · Apache-2.0 · 2eae60e

BDD with Approval Tests

The Problem

Specifications live in documents. They drift from reality because nothing enforces them.

Tests verify implementation. Written after code, they document what IS, not what SHOULD BE. They're noisy. You can't glance at them and quickly validate correctness.

You need an artifact that:

  • Captures expected behavior before code exists
  • Stays in sync because it's executable
  • A human can validate at a glance
Executable Specifications

The fixture file IS that artifact. Write it BEFORE implementation.

Think through scenarios by creating approval files. Describe expected behavior in domain language. Implementation is driven by making these specs pass. Specs stay executable, never go stale.

A human looks at the fixture and immediately sees: correct or not. No translation between "spec" and "test". They're the same artifact.

For the approval testing technique itself (verify, scrubbers, combinations), see /approval-tests. For nulled infrastructure in system tests, see /nullables.

Approved Fixtures

Test files combining input and expected output in a format designed for human validation.

## Input
(context, parameters, initial state)

## Output
(expected results, side effects, final state)

Test runner reads fixtures, executes code, compares output. Adding test cases = adding files, not code.

Design the format for YOUR domain:

  • Grid/spatial problems → ASCII art
  • Transformations → before/after
  • Workflows → step sequences with results
  • API interactions → request/response pairs

See [references/approved-fixtures.md](references/approved-fixtures.md) for examples.

Format Design

The question: Can someone validate correctness in <5 seconds?

Design for human eyes, not machine parsing. Match the domain's natural representation. How you'd explain it on a whiteboard.

What makes formats scannable:

  • Columnar layouts with visual alignment
  • Consistent structure across all cases
  • Whitespace that groups related elements

Avoid:

  • Dense JSON (hard to scan)
  • Single-line formats (no visual structure)
  • Formats requiring mental parsing
Implementation

One-time per domain:

  1. Parser - extracts input from fixture format
  2. Formatter (printer) - converts actual output to fixture format
  3. Single test file discovers and runs all fixtures

Keep parser/formatter simple. Format should be close to natural representation.

Approved Logs

Turn production logs into tests by copying and fixing incorrect lines. Quick bug reproduction.

Caveat: Logs are for runtime observability, not test validation. Tying tests to log format creates coupling. Log changes break tests. Use sparingly when logs happen to capture the behavior well.

See [references/approved-logs.md](references/approved-logs.md).

按 Apache-2.0 许可原样转载,未经改动 · 在 GitHub 查看 →

评论

登录即可评论;带「已验证安装」的,是发布者名下有本店的安装或持有记录。