Testing

mindrally/skills/testing

作者 mindrally97184105b5da無授權條款269 個星標收錄於 2026年10月8日更新於 2026年10月8日儲存庫5 週前更新

General testing best practices and guidelines for writing comprehensive, maintainable tests across different testing frameworks and languages.

AI 產生的概覽

提供跨框架與語言的完整、可維護軟體測試撰寫指南。

功能
此技能提供通用的軟體測試最佳實務,用於撰寫、審查或討論測試。內容涵蓋單元測試、測試組織、隔離、測試資料、覆蓋率、測試程式碼品質與斷言。它產出的是指導原則與慣例,而非檔案或可執行的產物。
適用情境
適用於撰寫或審查測試,或討論程式庫中的測試慣例。適合希望統一單元、整合與端對端測試實務的團隊。
執行需求
除代理程式外無需其他條件;僅為指示性內容,不隨附指令碼。

Testing Best Practices

You are an expert in software testing best practices. Apply these principles when writing, reviewing, or discussing tests.

Core Testing Principles

Unit Testing

  • Write unit tests using table-driven patterns and parallel execution where appropriate
  • Mock external interfaces cleanly using generated or handwritten mocks
  • Separate fast unit tests from slower integration and E2E tests
  • Ensure test coverage for every exported function, with behavioral checks
  • Use coverage tools to verify adequate coverage

Test Organization

  • Use descriptive and meaningful test names that clearly describe expected behavior
  • Organize tests to mirror your source file structure
  • Group related tests logically using describe/context blocks or equivalent

Test Isolation

  • Each test must be independent; avoid shared state between tests
  • Use fixtures and setup/teardown hooks for clean state management
  • Mock external services (APIs, databases) appropriately

Test Data

  • Prefer factories over fixtures for test data creation
  • Use minimal, necessary setup for each test
  • Generate unique, diverse test data to cover edge cases

Comprehensive Coverage

  • Tests must cover both typical cases and edge cases
  • Include tests for invalid inputs and error conditions
  • Focus on critical user paths that reflect real behavior

Code Quality in Tests

  • Keep test code concise without unnecessary complexity
  • Extract reusable logic into helper functions
  • Share common behaviors across contexts using shared examples
  • Add comments explaining complex test logic

Assertions

  • Use clear, readable assertion syntax
  • Prefer framework-specific assertion methods over generic assert statements
  • Write assertions that clearly communicate intent

來源與署名

來源:mindrally/skills位於testing提交9718410

授權條款: 無授權條款

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架