AgentSkillsCN

Testing Test Writing

使用现代测试框架,针对关键用户流程和核心功能编写战略性、聚焦的测试,注重行为而非实现。在创建测试文件、编写单元测试、集成测试或端到端测试的测试目录(tests/、__tests__、spec/、*.test.js、*.spec.py)时使用此技能。在测试核心用户工作流和业务关键功能时应用此技能,实施测试驱动开发(TDD)的红绿重构周期,模拟外部依赖以进行隔离单元测试,使用清晰的描述性测试名称说明预期行为,遵循安排-执行-断言模式,确保测试快速且独立运行。此技能优先测试最重要内容(主要用户流程),同时推迟边缘情况和非关键路径到后期,强调行为测试而非实现细节以减少脆弱性,使用Jest、Playwright、Cypress、pytest、RSpec或Testing Library等现代框架,打造可靠、可维护的测试套件。

SKILL.md
--- frontmatter
name: Testing Test Writing
description: Write strategic, focused tests for critical user flows and core functionality using modern testing frameworks, focusing on behavior over implementation. Use this skill when creating test files, writing unit tests, integration tests, or end-to-end tests in test directories (tests/, __tests__, spec/, *.test.js, *.spec.py). Apply this skill when testing core user workflows and business-critical features, implementing test-driven development (TDD) with red-green-refactor cycles, mocking external dependencies for isolated unit tests, using clear descriptive test names that explain expected behavior, following arrange-act-assert patterns, and ensuring tests run fast and independently. This skill prioritizes testing what matters most (primary user flows) while deferring edge cases and non-critical paths until later, emphasizes behavior testing over implementation details to reduce brittleness, and uses modern frameworks like Jest, Playwright, Cypress, pytest, RSpec, or Testing Library for reliable, maintainable test suites.

Testing Test Writing

This Skill provides Claude Code with specific guidance on how to adhere to coding standards as they relate to how it should handle testing test writing.

When to use this skill

  • When creating test files in test directories (tests/, tests, spec/, *.test.js, *.spec.py)
  • When writing unit tests for core functions, classes, or business logic
  • When implementing integration tests for API endpoints, database interactions, or service layers
  • When creating end-to-end tests for critical user workflows using Playwright or Cypress
  • When practicing test-driven development (TDD) with red-green-refactor cycles
  • When testing behavior (what the code does) rather than implementation (how it does it)
  • When writing clear, descriptive test names that explain expected outcomes
  • When using arrange-act-assert (AAA) pattern to structure tests clearly
  • When mocking external dependencies (databases, APIs, file systems) for isolated unit tests
  • When ensuring tests are fast (milliseconds for unit tests) and run independently
  • When testing core user flows and primary functionality (deferring edge cases until later)
  • When working with testing frameworks (Jest, Vitest, pytest, RSpec, JUnit, Testing Library)
  • When implementing test fixtures, factories, or test data management
  • When ensuring tests provide value without slowing down development velocity

Instructions

For details, refer to the information provided in this file: testing test writing