AgentSkillsCN

Testing Test Writing

在开发过程中,应优先编写精简的战略性测试,重点聚焦于核心用户流程与关键路径,将全面的边缘场景测试延后至功能开发完成之后再行开展。这一技能适用于以下场景:为已上线的功能编写测试用例、针对关键用户工作流进行测试、实施集成测试、借助Playwright构建端到端测试、为核心逻辑编写单元测试,或是在制定测试策略与确定测试优先级时加以运用。无论是在处理测试文件(*.test.ts、*.spec.ts、*.test.tsx)、Playwright测试文件(e2e/*.spec.ts)、测试配置,还是在功能开发阶段决定究竟该测试哪些内容时,这一技能都能发挥重要作用。通过这一技能,我们能够在活跃开发阶段保持测试数量精简(先完成功能本身),只专注于核心用户流程与关键路径(跳过非关键的辅助功能),并将边缘场景与验证性测试推迟至专门的测试环节;同时,注重以行为为导向的测试,而非拘泥于实现细节(测试“做什么”,而非“怎么做”);采用清晰明了的测试名称,准确阐述测试行为与预期结果;通过模拟外部依赖(如数据库、API、文件系统)来实现单元间的隔离;确保单元测试执行速度极快,耗时仅以毫秒计;追求战略性的测试覆盖,而非面面俱到的全面覆盖;在前端E2E测试中选用Playwright,在后端及Bun项目中使用Bun测试运行器,在.NET项目中采用xUnit,在Python项目中则可借助pytest。

SKILL.md
--- frontmatter
name: Testing Test Writing
description: Write minimal strategic tests during development focusing on core user flows and critical paths, deferring comprehensive edge case testing until after feature completion. Use this skill when writing tests for completed features, testing critical user workflows, implementing integration tests, creating end-to-end tests with Playwright, writing unit tests for core logic, or determining testing strategy and priorities. Apply when working on test files (*.test.ts, *.spec.ts, *.test.tsx), Playwright test files (e2e/*.spec.ts), test configuration, or when deciding what to test during feature development. This skill ensures minimal tests during active development (complete the feature first), focus exclusively on core user flows and critical paths (skip non-critical utilities), deferred edge case and validation testing until dedicated testing phases, behavior testing over implementation details (test WHAT not HOW), descriptive test names that explain the behavior and expected outcome, mocked external dependencies (databases, APIs, file systems) to isolate units, fast unit test execution (milliseconds), strategic rather than comprehensive coverage, Playwright for frontend E2E tests, Bun test runner for backend/Bun projects, xUnit for .NET, and pytest for Python.

Testing Test Writing

When to use this skill:

  • When determining testing strategy for a new feature (minimal during dev)
  • When writing tests for completed features at logical milestones
  • When testing critical user workflows and primary paths only
  • When implementing integration tests for feature interactions
  • When creating end-to-end tests with Playwright for user journeys
  • When writing unit tests for core business logic
  • When deciding whether to write tests during or after development (prefer after)
  • When prioritizing which tests to write first (critical paths)
  • When mocking external dependencies (databases, APIs, file systems)
  • When writing descriptive test names that explain behavior and expected outcome
  • When working on test files (*.test.ts, .spec.ts, e2e/.spec.ts)
  • When reviewing testing coverage and identifying gaps in critical paths
  • When choosing test runners (Bun test for Bun, xUnit for .NET, pytest for Python)
  • When skipping edge case tests during active feature development

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.

Instructions

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