Token导航 LogoToken导航TokenDH.com
开发规范敏感数据github未标认证来源可访问许可证需确认审计通过

testing-best-practices测试最佳实践

Agent Skill

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

总安装

2,188

周安装

94

GitHub Stars

43

下载量

767
CodexClaudeCursorGemini CLI

安装说明

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

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

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

请帮我安装这个 Agent Skill:testing-best-practices(测试最佳实践)
来源仓库:https://github.com/0xbigboss/claude-code
仓库路径:skills/testing-best-practices
安装命令:
npx skills add https://github.com/0xbigboss/claude-code --skill testing-best-practices
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

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

skills.shnpx skills
npx skills add https://github.com/0xbigboss/claude-code --skill testing-best-practices

简介

适用于需要提升代码测试覆盖率和质量保障效率的开发场景。

  • 核心能力包括单元测试编写、集成测试验证、测试数据驱动设计和边界条件覆盖。
  • 使用时需确认项目测试框架、运行命令及夹具配置, 避免为通过测试而破坏真实逻辑。testing-best-practices 属于开发规范类 Skill,可作为该场景下的辅助能力补充。
  • 安装需通过 GitHub 仓库方式,并确保宿主环境支持相关技能调用。

SKILL.md

Test layering policy

Unit tests

Purpose: verify individual functions and invariants in isolation.

  • Data-driven: parameterized tables covering happy path, boundary, error, and edge cases.
  • Property-based: fuzz invariants that must hold across all inputs (e.g., idempotency, sort stability, roundtrip serialization).
  • Derive cases from the module's public API surface: input types/constraints, output shape, error modes, invariants.

Integration / contract tests

Purpose: verify interactions between components and external services.

  • API envelope: request/response shape, status codes, content types, pagination.
  • Error contract: error codes, error shapes, rate limiting, retries.
  • Auth and scoping: token validation, role-based access, tenant isolation.
  • Eventual consistency: verify convergence within bounded time; poll rather than sleep.
  • Reuse auth state across tests where possible; avoid redundant login flows.

E2E tests

Purpose: verify real user workflows through the full stack.

  • No mocks; exercise real services, databases, and APIs.
  • Happy-path workflows only; save edge cases for lower layers.
  • State-tolerant: never assume a clean slate; tolerate and work with prior state.
  • Idempotent: safe to run repeatedly without cleanup between runs.
  • Flow-oriented: validate real data paths end-to-end rather than isolated assertions.

Hard rules

  • Never invent signatures, source locations, or line numbers. Only reference what you have read from the codebase.
  • No fabricated fixtures. Derive test data from actual schemas, types, or seed data in the repo.
  • No test-only hacks in product code. No if (process.env.TEST) branches, no test-specific exports, no test backdoors.
  • E2E must not rely on clean slate. Tests must tolerate pre-existing data, prior test runs, and shared environments.

Execution guidance

Preflight checks (before e2e)

  1. Verify the target environment is reachable (health endpoint, ping).
  2. Confirm required services are running (database, API, auth provider).
  3. Validate test user / credentials exist and are functional.
  4. Check for leftover state that could cause false failures; log it, do not fail on it.

Deterministic fixtures

  • Use seeded randomness for generated data (seeded faker, deterministic UUIDs).
  • Fixtures should be self-contained; avoid cross-test fixture dependencies.
  • Prefer factory functions over shared mutable fixture objects.

Async handling

  • Poll with bounded timeout and backoff; never use fixed sleep/waitForTimeout.
  • Set explicit timeout per operation; fail fast with a descriptive message on timeout.
  • Bound retry attempts (e.g., max 3 retries with exponential backoff).
  • Use framework-native waiting (Playwright expect, async assertions) over manual loops.

Flake handling

  • Single infrastructure retry per test run; if it fails twice, it is not flake.
  • On retry failure, collect diagnostics: screenshots, network logs, service health, timestamps.
  • Classify the failure (flaky / outdated / bug) before attempting a fix.
  • Never add arbitrary delays or retry loops as a flake "fix."

API surface discovery

Before generating test cases:

  • Read the module source to enumerate exports/public functions.
  • Confirm scope from the user request and inspected code context; if ambiguous, state assumptions and proceed conservatively.
  • For each function: input types/constraints, output shape, error modes, invariants.
  • Probe for state dependencies and ordering constraints between functions.

Output format

Use markdown. Produce three sections:

Test Strategy -- one bullet per layer (unit/integration/e2e) naming the functions/flows and their coverage type.

Test Matrix -- table per function: columns ID | Category | Name | Input | Expected. Case ID scheme: {CATEGORY}-{NN} (HP, BV, ERR, EDGE). Append-only; never renumber.

Implementation Plan -- ordered steps: fixtures, unit tests, integration tests, e2e flows, run command.

CI guidance

Fast PR smoke lane

  • Unit tests + linting + type-check on every PR.
  • Subset of integration tests covering critical contracts.
  • Target: under 5 minutes.

Nightly full lane

Full unit + integration + e2e suite with higher property-based iteration counts. Flag tests that pass on retry but failed initially.

Workflow

  1. Spec or code defines the module behavior (types, constraints, API surface).
  2. Agent (with this skill) produces test strategy, matrix, and implementation plan.
  3. test-writer agent translates the plan to runnable code in the target language's idiom.
  4. Developer implements to pass the tests.
  5. If implementation reveals missing cases, propose them first; append to spec only when explicitly requested.

适合场景

01

用户想查找某类 Agent Skill 时

02

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

03

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

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

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

能力 4

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

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

平台分布

Codex

34.59%
按下载量换算265

Claude

29.21%
按下载量换算224

Cursor

17.5%
按下载量换算134

Gemini CLI

8.96%
按下载量换算69

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

敏感数据

该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

安装前确认

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

来源信息

继续浏览同类 Skills