属性测试
property-based-testing
属性测试的增量推广策略,在保留可读的基于示例的测试的同时,添加以不变量为中心的随机验证。适用于添加随机测试、验证输入范围,或验证数学属性。不适用于:基于示例的单元/集成测试或 TDD 工作流(使用 test-driven-development)、React 组件测试(使用 ui-testing),或 E2E 浏览器测试(使用 webapp-testing)。
- License 许可
- MIT
- 最近更新
- 2026-08-16
- Stars
- ★ 3
- Forks
- 0
01 前言 Front Matter
- name
- property-based-testing
- description
- Incremental rollout policy for property-based testing that preserves readable example-based tests while adding invariant-focused randomized verification. Use when adding randomized testing, validating input ranges, or verifying mathematical properties. DO NOT USE FOR: example-based unit/integration tests or TDD workflow (use test-driven-development), React component tests (use ui-testing), or E2E browser tests (use webapp-testing).
03 SKILL.md 正文
Property-Based Testing Skill
Use PBT as a complement to example-based tests.
Rollout Policy
- Start in domain logic with pure invariants first.
- Keep existing unit/integration tests as readability and regression anchors.
- Begin with small run counts in PR CI, then increase in scheduled or nightly runs.
- Require reproducible seeds in all failure reports.
- Avoid initial rollout in UI/adapters until core invariants are stable.
Guardrails
- Do not replace readable example-based tests with PBT.
- Keep properties behavior-focused, not implementation-coupled.
- Treat flaky generators/shrinking issues as
test defectand route for test refinement. - If infrastructure instability dominates, classify as
harness/env defectand fix the harness before expanding PBT scope.
Adoption Guidance
- Start with a small invariant set and expand gradually.
- Add PBT where domain rules are stable and deterministic.
- Scale run volume only after repeated stable results.
Gotchas
| Trigger | Gotcha | Fix |
|---|---|---|
| Replacing readable example-based tests with PBT to be "more thorough" | Example-based tests serve as readable documentation and regression anchors; removing them loses context | PBT complements, never replaces, example-based tests |
| Writing a property that asserts internal computation steps | Property breaks on any internal refactor, same flaw as testing implementation details | Keep properties behavior-focused; test invariants (observable outcomes), not mechanisms |
| Adding PBT to UI or adapter layers before core domain invariants are stable | Unstable core means properties change constantly; high churn | Start in domain logic with pure invariants; expand outward after stability |
Setting runs: 1000 in CI from the start |
Slow CI blocks the team immediately on PBT adoption | Start small in CI (50–100 runs); increase in scheduled or nightly runs after stability confirmed |
| Not requiring reproducible seeds in failure reports | Intermittent PBT failure looks flaky but is reproducible with the right seed | Require seed capture in all failure reports from day one |
| Treating intermittent PBT failures as domain bugs without triage | Root cause may be the generator or shrinking logic, not domain code | Classify as test defect, route to test refinement before investigating domain code |
04 同仓库更多 Skills
Playwright 端到端测试
webapp-testing
面向 Web 应用的 Playwright 端到端测试指南,包含实用模式和设置步骤。在创建或改进基于浏览器的 E2E 覆盖率、测试稳定性和 CI 执行时使用。不要用于:React 组件测试(使用 ui-testing)、Canvas 游戏交互(使用 browser-canvas-testing)、TDD 工作流(使用 test-driven-development)、失败调试(使用 systematic-debugging)或随机化属性测试(使用 property-based-testing)。
任务完成前验证
verification-before-completion
在将工作标记为完成前使用的基于证据的验证清单。适用于提交 PR、发布、将工单标记为完成,或任何「我已完成」的声明之前;也适用于为差异测试套件的主张指定基线提交、设计变异测试活动或红灯运行证据、做出「不存在」的主张、普遍性主张,或将一次性演示作为长期保证提供时、归因某项测量结果或声称某次扫描或验证循环已完成时,以及陈述某项检查或 CI 套件将如何处理某个变更时。不要用于:合并后清理或归档(使用 post-pr-review),或处理 GitHub 审查意见(使用 code-review-intake)。
验证与审查方法论
validation-methodology
用于分阶段验证、故障分诊和追查深度设置的可复用验证与审查方法论。在运行验证阶梯、对失败进行分诊或执行对抗性审查时使用。不要用于:CE Gate 编排、专家派发的职责归属或步骤执行流程(这些保留在 Code-Conductor 中)。
上游智能体接手协议
upstream-onboarding
供上游智能体(Experience-Owner、Solution-Designer、Issue-Planner)与 Code-Conductor 在针对现有 GitHub issue 被调用时使用的共享开场阶段协议。它会生成适配规模的上下文简报,并在每个阶段边界对承接的工作执行标准检查。当用户可调用的智能体收到引用现有 GitHub issue 的请求、且必须在开场阶段加载 solution-authoring 与 upstream-onboarding 时使用。不要用于:子智能体派发(其已在经评估的会话上下文中运行)、合并后审查(使用 post-pr-review)、研究类或非树形子智能体。
React 组件测试策略
ui-testing
以用户行为为核心的弹性 React 组件测试策略。适用于编写或审阅组件级 React 测试、修复不稳定的组件测试,或建立 React 测试模式。不适用于:Playwright E2E 测试(使用 webapp-testing)、canvas 游戏交互(使用 browser-canvas-testing)、TDD 工作流(使用 test-driven-development)、失败调试(使用 systematic-debugging)、UI 组件设计(使用 frontend-design),或随机属性测试(使用 property-based-testing)。
UI 界面视觉迭代优化
ui-iteration
可复用的截图驱动 UI 打磨工作流,用于迭代式视觉优化。适用于通过反复审阅与调整来改进布局、层级、间距、反馈或基于 Tailwind 的呈现效果。不适用于:功能性 Bug 修复、仅针对无障碍的审计,或重大重设计策略工作(使用 Code-Smith 或 frontend-design)。