testing

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Testing Skill

测试Skill

Comprehensive testing domain for pytest-based projects. Provides test generation, review, execution, and specialized testing workflows with automatic routing based on user intent.
这是针对基于pytest的项目的综合性测试领域,提供测试生成、评审、执行功能,以及可根据用户意图自动路由的专属测试工作流。

Auto-Activation Keywords

自动激活关键词

This skill activates automatically when you mention:
  • test, tests, testing
  • coverage, test coverage
  • pytest, unittest
  • integration test, unit test, e2e test
  • performance test, benchmark, load test
  • security test, penetration test
  • test review, test quality
当你提及以下内容时,该Skill会自动激活:
  • test、tests、testing
  • coverage、测试覆盖率
  • pytest、unittest
  • integration test(集成测试)、unit test(单元测试)、e2e test(端到端测试)
  • performance test(性能测试)、benchmark(基准测试)、load test(负载测试)
  • security test(安全测试)、penetration test(渗透测试)
  • test review(测试评审)、test quality(测试质量)

Routing Logic

路由逻辑

Based on user intent, this skill routes to appropriate workflows:
根据用户意图,该Skill会路由至对应的工作流:

Test Generation

测试生成

Keywords: "generate tests", "create tests", "write tests", "test coverage"
  • Simple test generation → Use
    /testing/generate
    workflow
  • Complex test strategy → Invoke
    test-engineer
    agent
关键词:"generate tests"(生成测试)、"create tests"(创建测试)、"write tests"(编写测试)、"test coverage"(测试覆盖率)
  • 简单测试生成 → 使用
    /testing/generate
    工作流
  • 复杂测试策略 → 调用
    test-engineer
    agent

Test Review

测试评审

Keywords: "review tests", "test quality", "coverage gaps", "improve tests"
  • Review existing tests → Use
    /testing/review
    workflow
  • Comprehensive quality audit → Invoke
    test-engineer
    agent
关键词:"review tests"(评审测试)、"test quality"(测试质量)、"coverage gaps"(覆盖率缺口)、"improve tests"(优化测试)
  • 评审现有测试 → 使用
    /testing/review
    工作流
  • 全面质量审计 → 调用
    test-engineer
    agent

End-to-End Testing

端到端测试

Keywords: "e2e test", "end-to-end", "full workflow", "integration test", "pipeline test"
  • E2E test generation → Use
    /testing/e2e
    workflow
  • Complex multi-component → Invoke
    test-engineer
    agent
关键词:"e2e test"(端到端测试)、"end-to-end"(端到端)、"full workflow"(完整工作流)、"integration test"(集成测试)、"pipeline test"(流水线测试)
  • E2E测试生成 → 使用
    /testing/e2e
    工作流
  • 复杂多组件测试 → 调用
    test-engineer
    agent

Performance Testing

性能测试

Keywords: "performance test", "benchmark", "load test", "memory usage", "speed test"
  • Performance test creation → Use
    /testing/performance
    workflow
  • Comprehensive performance analysis → Invoke
    test-engineer
    agent
关键词:"performance test"(性能测试)、"benchmark"(基准测试)、"load test"(负载测试)、"memory usage"(内存占用)、"speed test"(速度测试)
  • 性能测试创建 → 使用
    /testing/performance
    工作流
  • 全面性能分析 → 调用
    test-engineer
    agent

Security Testing

安全测试

Keywords: "security test", "vulnerability", "penetration test", "OWASP", "injection"
  • Security test generation → Use
    /testing/security
    workflow
  • Full security audit → Invoke
    security-auditor
    agent
关键词:"security test"(安全测试)、"vulnerability"(漏洞)、"penetration test"(渗透测试)、"OWASP"、"injection"(注入)
  • 安全测试生成 → 使用
    /testing/security
    工作流
  • 全面安全审计 → 调用
    security-auditor
    agent

Test Execution

测试执行

Keywords: "run tests", "execute tests", "test results", "pytest command"
  • Quick reference → See context/pytest-commands.md
  • Custom test execution → Use bash with pytest commands
关键词:"run tests"(运行测试)、"execute tests"(执行测试)、"test results"(测试结果)、"pytest command"(pytest命令)
  • 快速参考 → 查看context/pytest-commands.md
  • 自定义测试执行 → 使用bash执行pytest命令

Workflow Quick Reference

工作流快速参考

bash
undefined
bash
undefined

Generate comprehensive tests

Generate comprehensive tests

/testing/generate [module-path]
/testing/generate [module-path]

Review test quality

Review test quality

/testing/review [test-directory]
/testing/review [test-directory]

Create E2E tests

Create E2E tests

/testing/e2e [workflow-name]
/testing/e2e [workflow-name]

Create performance tests

Create performance tests

/testing/performance [component]
/testing/performance [component]

Create security tests

Create security tests

/testing/security [attack-vector]
undefined
/testing/security [attack-vector]
undefined

Complex Task Delegation

复杂任务委托

For complex multi-step testing tasks, invoke the
test-engineer
agent via Task tool:
Use test-engineer agent when:
- Designing comprehensive test strategy across multiple components
- Creating complete test suites from scratch (unit + integration + e2e)
- Optimizing test performance and coverage simultaneously
- Integrating multiple testing types (functional + performance + security)
对于复杂的多步骤测试任务,可通过Task工具调用
test-engineer
agent:
Use test-engineer agent when:
- Designing comprehensive test strategy across multiple components
- Creating complete test suites from scratch (unit + integration + e2e)
- Optimizing test performance and coverage simultaneously
- Integrating multiple testing types (functional + performance + security)

Supporting Context

支持上下文

  • Pytest patterns: See
    context/pytest-patterns.md
    for common test patterns
  • Common commands: See
    context/pytest-commands.md
    for frequently used commands
  • Coverage standards: Minimum 80% coverage required (see
    /standards/python.md
    )
  • Pytest patterns:查看
    context/pytest-patterns.md
    获取常见测试模式
  • Common commands:查看
    context/pytest-commands.md
    获取常用命令
  • Coverage standards:要求最低80%的测试覆盖率(详见
    /standards/python.md

Integration Points

集成点

Agents

Agents

  • test-engineer: Comprehensive test strategy and generation
  • security-auditor: Security-focused testing and vulnerability analysis
  • test-engineer:提供全面的测试策略与生成服务
  • security-auditor:专注于安全测试与漏洞分析

MCP Tools

MCP Tools

  • mcp__zen-core__chat: Multi-model consensus for complex test design decisions
  • mcp__zen-core__chat:为复杂测试设计决策提供多模型共识支持

Hooks

Hooks

  • TDD enforcement: Pre-Write/Edit hook enforces test-first development
  • TDD enforcement:Pre-Write/Edit钩子可强制执行测试先行的开发模式

Standards

Standards

  • Python testing standards:
    /standards/python.md
    (80%+ coverage requirement)
  • Linting standards:
    /standards/linting.md
    (pytest configuration)
  • Python测试标准:
    /standards/python.md
    (要求80%以上的测试覆盖率)
  • 代码检查标准:
    /standards/linting.md
    (pytest配置相关)

Testing Standards Summary

测试标准汇总

Required for all projects:
  • Minimum 80% test coverage
  • Unit tests in
    tests/unit/
    (< 1s each)
  • Integration tests in
    tests/integration/
    (< 5s each)
  • E2E tests in
    tests/e2e/
    (marked @pytest.mark.e2e)
  • Proper pytest markers (@pytest.mark.unit, .integration, .slow, .security, .perf)
  • AAA pattern (Arrange-Act-Assert)
  • Clear test naming (test_should_[expected]when[condition])
Fixture management:
  • Use existing fixtures from conftest.py
  • No hardcoded test data
  • Appropriate fixture scope (function, class, module, session)
Test execution:
bash
undefined
所有项目必须满足:
  • 最低80%的测试覆盖率
  • 单元测试存放于
    tests/unit/
    目录(每个测试耗时<1秒)
  • 集成测试存放于
    tests/integration/
    目录(每个测试耗时<5秒)
  • 端到端测试存放于
    tests/e2e/
    目录(标记为@pytest.mark.e2e)
  • 使用正确的pytest标记(@pytest.mark.unit、.integration、.slow、.security、.perf)
  • 遵循AAA模式(准备-执行-断言)
  • 清晰的测试命名规范(test_should_[预期结果]when[条件])
Fixture管理:
  • 使用conftest.py中的现有fixture
  • 禁止使用硬编码测试数据
  • 选择合适的fixture作用域(function、class、module、session)
测试执行:
bash
undefined

Standard test run with coverage

Standard test run with coverage

poetry run pytest -v --cov=src --cov-report=html --cov-report=term-missing --cov-fail-under=80
poetry run pytest -v --cov=src --cov-report=html --cov-report=term-missing --cov-fail-under=80

Fast dev cycle (skip slow tests)

Fast dev cycle (skip slow tests)

poetry run pytest -m "not slow"
poetry run pytest -m "not slow"

Specific test categories

Specific test categories

poetry run pytest tests/unit/ # Unit tests only poetry run pytest tests/integration/ # Integration tests poetry run pytest -m security # Security tests poetry run pytest -m perf # Performance tests
undefined
poetry run pytest tests/unit/ # Unit tests only poetry run pytest tests/integration/ # Integration tests poetry run pytest -m security # Security tests poetry run pytest -m perf # Performance tests
undefined

Examples

示例

Example 1: Generate tests for new module
User: "Generate comprehensive tests for the payment processor module"
→ Skill routes to /testing/generate workflow
→ Workflow creates unit, integration, and security tests
→ Ensures 80%+ coverage for payment processor
Example 2: Review test quality
User: "Review the tests for the authentication system and suggest improvements"
→ Skill routes to /testing/review workflow
→ Workflow analyzes coverage, patterns, fixture usage
→ Provides actionable recommendations
Example 3: Complex test strategy
User: "Design a comprehensive testing strategy for the new RAG pipeline"
→ Skill invokes test-engineer agent
→ Agent creates multi-tier testing approach:
  - Unit tests for embeddings, chunking, retrieval
  - Integration tests for pipeline flows
  - E2E tests for complete query-response cycles
  - Performance tests for large document handling

This skill consolidates test-generator, test-reviewer, e2e-tester, performance-tester, and security-tester into a unified testing domain with intelligent routing.
示例1:为新模块生成测试
用户:"为支付处理器模块生成全面的测试用例"
→ Skill路由至/testing/generate工作流
→ 工作流创建单元、集成与安全测试
→ 确保支付处理器模块的测试覆盖率达到80%以上
示例2:评审测试质量
用户:"评审认证系统的测试用例并提出改进建议"
→ Skill路由至/testing/review工作流
→ 工作流分析覆盖率、测试模式、fixture使用情况
→ 提供可执行的改进建议
示例3:复杂测试策略设计
用户:"为新的RAG流水线设计全面的测试策略"
→ Skill调用test-engineer agent
→ Agent创建多层级测试方案:
  - 针对嵌入、分块、检索功能的单元测试
  - 针对流水线流程的集成测试
  - 针对完整查询-响应周期的端到端测试
  - 针对大文档处理的性能测试

该Skill整合了test-generator、test-reviewer、e2e-tester、performance-tester和security-tester,形成一个具备智能路由功能的统一测试领域。