Token导航 LogoToken导航TokenDH.com
开发规范只读github未标认证来源可访问clear审计通过

testing-best-practices测试最佳实践

Agent Skill

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

总安装

3,504

周安装

149

GitHub Stars

33

下载量

1,228
CodexClaudeCursorGemini CLI

安装说明

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

GitHub

来源数

3

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

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

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

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/asyrafhussin/agent-skills --skill testing-best-practices

简介

用于遵循行业标准的测试方法和质量保障流程。

  • 适合制定测试计划、评审用例并输出规范文档。
  • 涵盖可读性、可维护性和覆盖率等关键指标。适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。
  • 应结合团队实际调整实践强度,避免过度工程化。
  • testing-best-practices 属于开发规范类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

Testing Best Practices

Unit testing, integration testing, and TDD principles for reliable, maintainable test suites. Contains 34 rules across 7 categories using TypeScript with Jest/Vitest.

Metadata

  • Version: 2.0.0
  • Rule Count: 34 rules across 7 categories
  • License: MIT

When to Apply

Reference these guidelines when:

  • Writing unit or integration tests
  • Reviewing test code quality
  • Improving test coverage strategy
  • Setting up testing infrastructure
  • Debugging flaky or slow tests

Rule Categories by Priority

PriorityCategoryImpactPrefix
1Test StructureCRITICALstruct-
2Test IsolationCRITICALiso-
3AssertionsHIGHassert-
4Test DataHIGHdata-
5MockingMEDIUMmock-
6CoverageMEDIUMcov-
7PerformanceLOWperf-

Quick Reference

1. Test Structure (CRITICAL)

  • struct-aaa-pattern - Arrange, Act, Assert pattern
  • struct-descriptive-names - Descriptive test names
  • struct-one-assertion - One logical assertion per test
  • struct-describe-it - Organized test suites with describe/it
  • struct-given-when-then - BDD style when appropriate
  • struct-setup-teardown - Proper setup and teardown

2. Test Isolation (CRITICAL)

  • iso-independent-tests - Tests run independently
  • iso-no-shared-state - No shared mutable state
  • iso-deterministic - Same result every run
  • iso-no-order-dependency - Run in any order
  • iso-cleanup - Clean up after tests
  • iso-test-doubles - Strategic use of test doubles

3. Assertions (HIGH)

  • assert-specific - Use specific assertions
  • assert-meaningful-messages - Helpful failure messages
  • assert-expected-actual - Expected value first
  • assert-no-magic-numbers - Use named constants
  • assert-custom-matchers - Custom matchers for domain logic

4. Test Data (HIGH)

  • data-factories - Use factories for test data
  • data-builders - Builder pattern for complex objects
  • data-faker - Generate realistic fake data
  • data-minimal - Minimal test data
  • data-realistic - Realistic edge cases
  • data-fixtures - Manage test fixtures

5. Mocking (MEDIUM)

  • mock-boundaries - Mock only at boundaries
  • mock-verify-interactions - Verify important mock calls
  • mock-minimal - Don't over-mock
  • mock-realistic - Realistic mock behavior with MSW

6. Coverage (MEDIUM)

  • cov-meaningful - Focus on meaningful coverage
  • cov-edge-cases - Cover edge cases and boundary values
  • cov-unhappy-paths - Test error scenarios
  • cov-not-100-percent - 100% coverage isn't the goal

7. Performance (LOW)

  • perf-fast-unit - Keep unit tests fast (<50ms each)
  • perf-parallel - Run tests in parallel
  • perf-test-organization - Organize tests for fast feedback

Essential Guidelines

AAA Pattern (Arrange, Act, Assert)

it('calculates total with discount', () => {
  // Arrange
  const cart = new ShoppingCart();
  cart.addItem({ name: 'Book', price: 20 });
  cart.applyDiscount(0.1);

  // Act
  const total = cart.getTotal();

  // Assert
  expect(total).toBe(18);
});

Descriptive Test Names

// ✅ Describes behavior and scenario
describe('UserService.register', () => {
  it('creates user with hashed password', () => {});
  it('throws ValidationError when email is invalid', () => {});
  it('sends welcome email after successful registration', () => {});
});

Test Isolation

// ✅ Each test sets up its own data
beforeEach(() => {
  mockRepository = { save: vi.fn(), find: vi.fn() };
  service = new OrderService(mockRepository);
});

How to Use

Read individual rule files for detailed explanations:

rules/struct-aaa-pattern.md
rules/iso-independent-tests.md
rules/mock-boundaries.md
rules/cov-meaningful.md

References

Full Compiled Document

For the complete guide with all rules expanded: AGENTS.md

适合场景

01

用户想查找某类 Agent Skill 时

02

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

03

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

04

需要参考平台分布和安装热度时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

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

能力 4

补充不同宿主或平台的使用分布数据

能力 5

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

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

平台分布

Claude Code

31.62%
按下载量换算388

Antigravity

21.45%
按下载量换算263

Codex

18.31%
按下载量换算225

Gemini CLI

13.62%
按下载量换算167

windsurf

6.92%
按下载量换算85

github-copilot

3.39%
按下载量换算42

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

只读

该 Skill 主要提供规则、说明或参考内容,本身偏只读;真正读写文件、联网或执行命令仍取决于宿主 Agent 的任务。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。

来源信息

继续浏览同类 Skills