Token导航 LogoToken导航TokenDH.com
开发external-servicegithub未标认证来源可访问许可证需确认审计通过

unit-test-philosophy单元测试哲学

Agent Skill

用于辅助测试设计、自动化测试、用例整理和回归验证。它适合让 Agent 编写单元测试、端到端测试、测试计划或根据失败日志定位问题。使用时需要确认项目测试框架、运行命令和夹具数据,避免为了通过测试而改坏真实逻辑;涉及浏览器或外部服务时,应区分本地模拟、测试环境和生产环境。

总安装

470

周安装

20

GitHub Stars

30

下载量

165
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:unit-test-philosophy(单元测试哲学)
来源仓库:https://github.com/open-agreements/open-agreements
仓库路径:skills/unit-test-philosophy
安装命令:
npx skills add https://github.com/open-agreements/open-agreements --skill unit-test-philosophy
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/open-agreements/open-agreements --skill unit-test-philosophy

简介

单元测试哲学用于辅助测试设计和用例编写。

  • 适合生成单元测试或端到端测试。unit-test-philosophy 属于开发类 Skill,可作为该场景下的辅助能力补充。
  • 使用时需确认项目测试框架和运行命令。
  • 避免为了通过测试而改坏真实逻辑。适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。
  • 涉及浏览器时应区分本地模拟和环境。

SKILL.md

Unit Test Philosophy (Open Agreements)

Security model

  • This skill is guidance only — it does not execute tests or modify code directly.
  • All test commands are provided for the user or agent to run in their local environment.
  • No network access, credentials, or external services are required.

Use this skill when

  • A request asks to add tests, improve coverage, or harden regressions.
  • A change touches src/, integration-tests/, packages/contracts-workspace, or packages/contracts-workspace-mcp.
  • You need readable Allure behavior specs and OpenSpec traceability.

Core philosophy

  1. Test highest-risk behavior first. Focus first on mutating flows, parser/validator boundaries, and policy/safety checks.
  2. Optimize for regression prevention, not just line coverage. Prioritize branches where failures could produce wrong legal output or unsafe automation behavior.
  3. Treat Allure as test style, not test type. Use normal unit/integration tests with Allure labels, steps, and attachments in the same files.
  4. Keep spec and test effectively coextensive. If behavior is important enough to test, map it to canonical OpenSpec scenarios or active change-package scenarios.
  5. Keep assertions behavior-oriented. Verify user-observable outputs, diagnostics, and mutation outcomes before internals.
  6. Make failures easy to debug. Attach structured context for inputs, normalized outputs, and error payloads.

Repo standards

Test structure

  • Use Given/When/Then/And wording in Allure step titles.
  • Keep scenario steps as top-level test steps; avoid wrapping the full test body in synthetic container steps like Execute test body.
  • Prefer one assertion per step where practical.
  • Multiple assertions in one step are acceptable when they validate one cohesive invariant.
  • Keep tests deterministic (fixed fixtures, explicit env flags, no timing assumptions).

Allure API

  • Prefer repo helpers over direct raw Allure calls:

- integration-tests/helpers/allure-test.ts - Common helpers: itAllure, testAllure, allureStep, allureJsonAttachment, allurePrettyJsonAttachment, allureWordLikeTextAttachment, allureParameter, allureSeverity

  • Do not import from allure-vitest in tests.
  • Keep helper usage consistent across src/**/*.test.ts and integration-tests/**/*.test.ts.
  • For complex fixtures/stateful flows, attach:

- a pretty JSON artifact for request/result payloads - a human-readable “Word-like” artifact for document/checklist state before and after mutation when relevant

  • Rendering note: HTML preview attachments rely on the report post-process sanitizer allowlist patch (scripts/patch_allure_html_sanitizer.mjs, invoked by npm run report:allure). Do not bypass this pipeline when generating reports for review.

File naming and placement

  • Use collocated test files like src/<module>.test.ts.
  • Add Allure style inside these tests; do not split by "allure-only" test types by default.
  • Keep one test file focused on one module or capability.
  • Migration policy: gradually rename legacy *.allure.test.ts files to *.test.ts; do not introduce new *.allure.test.ts files.

OpenSpec traceability

  • Use .openspec('OA-###') whenever a matching scenario ID exists for the behavior.
  • Scenario IDs may come from either canonical specs (openspec/specs/open-agreements/spec.md) or active change-package specs (openspec/changes/<change-id>/specs/open-agreements/spec.md).
  • Pre-canonical IDs from active change packages are valid during implementation and should remain stable when promoted into canonical specs.
  • For new important behavior, add scenario IDs in the active change package first, map tests immediately, then promote those IDs into canonical specs when archiving.

Coverage expansion workflow

  1. Read coverage summaries and identify branch-heavy modules in src/core/** and integration flows.
  2. Rank by blast radius and mutation risk.
  3. Add tests in this order:

- Validation and error branches - Strict vs permissive behavior - No-partial-mutation / transactional guarantees - Invariants (deterministic outputs, schema safety, idempotency)

  1. Run targeted tests first, then full suite and coverage.

Severity recommendation rubric

  • critical: mutation correctness, legal-output integrity, data-loss risk, security/policy guardrails.
  • normal: standard behavior and compatibility scenarios.
  • minor: narrow edge cases with low production impact.
  • Apply severity based on failure impact, not module ownership.

Command checklist

npm run test:run
npm run test:coverage
npm run check:spec-coverage
npm run check:allure-labels

Minimal test template (TypeScript)

import { describe, expect } from 'vitest';
import { itAllure as it, allureStep, allureJsonAttachment } from '../../../integration-tests/helpers/allure-test.js';

describe('checklist patch behavior', () => {
  it('applies replacement deterministically', async () => {
    let result: { ok: boolean };

    await allureStep('Given a valid patch payload', async () => {
      await allureJsonAttachment('patch-input.json', {
        patch_id: 'patch_001',
        operations: [{ op: 'replace', path: '/issues/0/status', value: 'CLOSED' }],
      });
    });

    await allureStep('When patch validation runs', async () => {
      result = { ok: true };
    });

    await allureStep('Then validation succeeds', async () => {
      expect(result!.ok).toBe(true);
    });
  });
});

Extended reference

  • See references/allure-test-spec-writing-guide.md for full Allure step-writing guidance.

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

38.9%
按下载量换算64

Claude

31.94%
按下载量换算53

Cursor

17.22%
按下载量换算28

Gemini CLI

8.3%
按下载量换算14

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

external-service

该 Skill 可能调用第三方服务、云服务或外部模型 API,使用前需要确认账号、额度、数据发送范围和服务条款。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills