Token导航 LogoToken导航

Agent Skill · 前端设计

testing-principles(测试原理)

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

testing-principles 是前端设计类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为需要联网;许可证信息还不明确,第三方扫描已通过,按安装量在前端设计类的 10,216 个 Skill 里排第 3,892。

总安装 1,073周安装 43GitHub Stars 323下载 347核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

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

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

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/shinpr/claude-code-workflows --skill testing-principles

这个 Skill 是做什么的

前端设计类 Skill 关注页面结构、视觉规范和组件写法,输出通常是可运行的界面代码。

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

安装方式:github,支持 Codex、Claude、Cursor、Gemini CLI。

来源仓库内路径:skills/testing-principles

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/shinpr/claude-code-workflows --skill testing-p…;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要需要联网,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

testing-principles 怎么安装?

在终端执行 npx skills add https://github.com/shinpr/claude-code-workflows --skill testing-principles。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

testing-principles 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

testing-principles 需要什么权限?

权限级别是需要联网。该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

testing-principles 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

testing-principles 用的人多吗?

公开数据是累计安装 1,073 次,近一周安装 43 次,下载 347 次,GitHub 323 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

testing-principles 安全吗?

第三方扫描结果为通过,但这只覆盖已知的静态检查项,不能替代自己读一遍源码和安装命令。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 第三方扫描已通过,常见的高风险行为没有命中。

先想清楚的地方

  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理前端设计类任务、又不想每次都手写提示词的人。

不太适合

  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

前端设计类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
frontend-design

前端设计 · Codex、Claude

8,823,360126,072只读MIT通过
vercel-composition-patterns

Vercel 组合模式 · Codex、Claude

3,858,81625,893需要联网MIT通过
vercel-react-native-skills

Vercel React native skills 前端 · Codex、Claude

2,468,66425,878只读MIT通过
adapt

adapt 搜索 · Codex、Claude

2,027,04023,125操作浏览器未明确通过
bolder

bolder 分析 · Codex、Claude

2,004,28823,130只读未明确通过
testing-principles

测试原理 · 本页

1,073323需要联网未明确通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

Language-Agnostic Testing Principles

Core Testing Philosophy

  1. Tests are First-Class Code: Maintain test quality equal to production code
  2. Fast Feedback: Tests should run quickly and provide immediate feedback
  3. Reliability: Tests should be deterministic and reproducible
  4. Independence: Each test should run in isolation

Test-Driven Development (TDD)

The RED-GREEN-REFACTOR Cycle

Always follow this cycle:

  1. RED: Write a failing test first

- Write the test before implementation - Ensure the test fails for the right reason - Verify test can actually fail

  1. GREEN: Write minimal code to pass

- Implement just enough to make the test pass - Focus on making it work

  1. REFACTOR: Improve code structure

- Clean up implementation - Eliminate duplication - Improve naming and clarity - Keep all tests passing

  1. VERIFY: Ensure all tests still pass

- Run full test suite - Check for regressions - Validate refactoring didn't break anything

TDD Benefits

  • Better design through testability requirements
  • Comprehensive test coverage by default
  • Living documentation of expected behavior
  • Confidence to refactor

Quality Requirements

Coverage Standards

  • Minimum 80% code coverage for production code
  • Prioritize critical paths and business logic
  • Prioritize meaningful assertions over coverage percentage
  • Use coverage as a guide, not a goal

Test Characteristics

All tests must be:

  • Independent: No dependencies between tests (see Test Independence Verification for detailed criteria)
  • Reproducible: Same input always produces same output
  • Fast: Unit tests < 100ms each, integration tests < 1s each, full suite < 10 minutes
  • Self-checking: Clear pass/fail without manual verification
  • Timely: Written close to the code they test

Test Types

Unit Tests

Purpose: Test individual components in isolation

Characteristics:

  • Test single function, method, or class
  • Fast execution (milliseconds)
  • No external dependencies
  • Mock external services
  • Majority of your test suite

Example Scope:

✓ Test calculateTotal() function
✓ Test UserValidator class
✓ Test parseDate() utility

Integration Tests

Purpose: Test interactions between components

Characteristics:

  • Test multiple components together
  • May include database, file system, or APIs
  • Slower than unit tests
  • Verify contracts between modules
  • Smaller portion of test suite

Example Scope:

✓ Test UserService with Database
✓ Test API endpoint with authentication
✓ Test file processing pipeline

End-to-End (E2E) Tests

Purpose: Test complete workflows from user perspective

Characteristics:

  • Test entire application stack
  • Simulate real user interactions
  • Slowest test type
  • Fewest in number
  • Highest confidence level

Example Scope:

✓ Test user registration flow
✓ Test checkout process
✓ Test complete report generation

Test Design Principles

AAA Pattern (Arrange-Act-Assert)

Structure every test in three clear phases:

// Arrange: Setup test data and conditions
user = createTestUser()
validator = createValidator()

// Act: Execute the code under test
result = validator.validate(user)

// Assert: Verify expected outcome
assert(result.isValid == true)

Adaptation: Apply this structure using your language's idioms (methods, functions, procedures)

One Assertion Per Concept

  • Test one behavior per test case
  • Multiple assertions OK if testing single concept
  • Split unrelated assertions into separate tests

Good:

test("validates user email format")           // input validation
test("returns error when service unavailable") // error path
test("transitions order from pending to paid") // state transition

Bad:

test("validates user") // Tests everything at once

Descriptive Test Names

Test names should clearly describe:

  • What is being tested
  • Under what conditions
  • What the expected outcome is

Recommended format: "should [expected behavior] when [condition]"

Examples:

test("should return error when email is invalid")
test("should calculate discount when user is premium")
test("should throw exception when file not found")

Adaptation: Follow your project's naming convention (camelCase, snake_case, describe/it blocks)

Test Independence

Setup and Teardown

  • Use setup hooks to prepare test environment
  • Use teardown hooks to clean up resources
  • Keep setup minimal and focused
  • Ensure teardown runs even if test fails

Mocking and Test Doubles

When to Use Mocks

  • Mock external dependencies: APIs, databases, file systems
  • Mock slow operations: Network calls, heavy computations
  • Mock unpredictable behavior: Random values, current time
  • Mock unavailable services: Third-party services

Mocking Principles

  • Mock at boundaries, not internally
  • Keep mocks simple and focused
  • Verify mock expectations when relevant
  • Wrap external libraries/frameworks behind adapters and mock the adapter

Data Layer Testing

Mock Limitations for Data Layer

Mocks validate call patterns but cannot verify data layer correctness. The following pass through undetected with mock-only testing:

  • Schema mismatches (table names, column names, data types)
  • Query correctness (joins, filters, aggregations, grouping)
  • Database constraints (NOT NULL, UNIQUE, foreign keys)
  • Migration drift (schema changes that make code out of sync)

When Mocks Are Appropriate for Data Access

  • Testing business logic that receives data from the data layer (mock the repository, test the service)
  • Testing error handling paths (simulating connection failures, timeouts)
  • Unit tests where data access is a dependency, not the subject under test

When Mocks Are Insufficient for Data Access

  • Testing repository or data access implementations themselves
  • Verifying query correctness (joins, filters, aggregations, grouping)
  • Testing data integrity constraints
  • Testing migration compatibility

Real Database Testing (Environment-Dependent)

Options for verifying data layer correctness against a real database engine:

  • Containerized databases for CI environments
  • In-memory databases for fast feedback (note: dialect differences may mask issues)
  • Dedicated test databases with seed data

The appropriate approach depends on project environment and CI/CD capabilities.

AI-Generated Code and Schema Awareness

  • AI-generated data access code has heightened schema hallucination risk
  • Generated queries may use correct syntax but reference nonexistent schema elements
  • Mock-based tests pass regardless of schema accuracy
  • Mitigation: Design Docs should include explicit schema references; code-verifier reverse coverage verifies data operations against documented schemas

Test Quality Practices

Keep Tests Active

  • Fix or delete failing tests: Resolve failures immediately
  • Remove commented-out tests: Fix them or delete entirely
  • Keep tests running: Broken tests lose value quickly
  • Maintain test suite: Refactor tests as needed

Test Helpers and Utilities

  • Create reusable test data builders
  • Extract common setup into helper functions
  • Build test utilities for complex scenarios
  • Share helpers across test files appropriately

What to Test

Focus on Behavior

Test observable behavior, not implementation:

✓ Good: Test that function returns expected output ✓ Good: Test that correct API endpoint is called ✗ Bad: Test that internal variable was set ✗ Bad: Test order of private method calls

Test Public APIs

  • Test through public interfaces
  • Avoid testing private methods directly
  • Test return values, outputs, exceptions
  • Test side effects (database, files, logs)

Test Edge Cases

Always test:

  • Boundary conditions: Min/max values, empty collections
  • Error cases: Invalid input, null values, missing data
  • Edge cases: Special characters, extreme values
  • Happy path: Normal, expected usage

Test Quality Criteria

These criteria ensure reliable, maintainable tests.

Literal Expected Values

  • Use hardcoded literal values in assertions
  • Calculate expected values independently from the implementation
  • If the implementation has a bug, the test catches it through independent verification
  • If expected value equals mock return value unchanged, the test verifies nothing (no transformation occurred)

Result-Based Verification

  • Verify final results and observable outcomes
  • Assert on return values, output data, or system state changes
  • For mock verification, check that correct arguments were passed

Meaningful Assertions

  • Every test must include at least one assertion
  • Assertions must validate observable behavior
  • A test without assertions always passes and provides no value

Appropriate Mock Scope

  • Mock direct external I/O dependencies: databases, HTTP clients, file systems
  • Use real implementations for internal utilities and business logic
  • Over-mocking reduces test value by verifying wiring instead of behavior

Boundary Value Testing

Test at boundaries of valid input ranges:

  • Minimum valid value
  • Maximum valid value
  • Just below minimum (invalid)
  • Just above maximum (invalid)
  • Empty input (where applicable)

Test Independence Verification

Each test must:

  • Create its own test data
  • Not depend on execution order
  • Clean up its own state
  • Pass when run in isolation

Verification Requirements

Before Commit

  • ✓ All tests pass — fix failing tests immediately
  • ✓ No tests skipped or commented — delete or fix
  • ✓ No debug code left in tests
  • ✓ Test coverage meets standards
  • ✓ No flaky tests — make deterministic
  • ✓ Tests run within performance thresholds

Test Organization

File Structure

  • Mirror production structure: Tests follow code organization
  • Clear naming conventions: Follow project's test file patterns

- Examples: UserService.test.*, user_service_test.*, test_user_service.*, UserServiceTests.*

  • Logical grouping: Group related tests together
  • Separate test types: Unit, integration, e2e in separate directories

Test Suite Organization

tests/
├── unit/           # Fast, isolated unit tests
├── integration/    # Integration tests
├── e2e/            # End-to-end tests
├── fixtures/       # Test data and fixtures
└── helpers/        # Shared test utilities

Performance Considerations

Test Speed

  • Unit tests: < 100ms each
  • Integration tests: < 1s each
  • Full suite: Should run frequently (< 10 minutes)

Optimization Strategies

  • Run tests in parallel when possible
  • Use in-memory databases for tests
  • Mock expensive operations
  • Split slow test suites
  • Profile and optimize slow tests

Continuous Integration

CI/CD Requirements

  • Run full test suite on every commit
  • Block merges if tests fail
  • Run tests in isolated environments
  • Test on target platforms/versions

Test Reports

  • Generate coverage reports
  • Track test execution time
  • Identify flaky tests
  • Monitor test trends

Test Design Guardrails

Every Test Must

  • Include at least one meaningful assertion
  • Create its own test data and clean up its own state
  • Pass when run in any order and in isolation
  • Test observable behavior through public interfaces
  • Keep test logic simple (no branching, no loops)
  • Mock only external I/O boundaries, use real implementations for internal logic

Flaky Test Resolution

  • Use deterministic time mocking instead of real clocks
  • Use fixed seed values instead of random data
  • Ensure proper resource cleanup in teardown
  • Resolve race conditions with synchronization primitives

Regression Testing

Prevent Regressions

  • Add test for every bug fix
  • Maintain comprehensive test suite
  • Run full suite regularly
  • Keep all tests unless the tested functionality is removed

Legacy Code

  • Add characterization tests before refactoring
  • Test existing behavior first
  • Gradually improve coverage
  • Refactor with confidence

Testing Best Practices by Language Paradigm

Type System Utilization

For languages with static type systems:

  • Leverage compile-time verification for correctness
  • Focus tests on business logic and runtime behavior
  • Use language's type system to prevent invalid states

For languages with dynamic typing:

  • Add comprehensive runtime validation tests
  • Explicitly test data contract validation
  • Consider property-based testing for broader coverage

Programming Paradigm Considerations

Functional approach:

  • Test pure functions thoroughly (deterministic, no side effects)
  • Test side effects at system boundaries
  • Leverage property-based testing for invariants

Object-oriented approach:

  • Test behavior through public interfaces
  • Mock dependencies via abstraction layers
  • Test polymorphic behavior carefully

Common principle: Adapt testing strategy to leverage language strengths while ensuring comprehensive coverage

Documentation and Communication

Tests as Documentation

  • Tests document expected behavior
  • Use clear, descriptive test names
  • Include examples of usage
  • Show edge cases and error handling

Test Failure Messages

  • Provide clear, actionable error messages
  • Include actual vs expected values
  • Add context about what was being tested
  • Make debugging easier

平台分布

Codex

32.56%
按下载量换算113

Claude

30.26%
按下载量换算105

Cursor

19.55%
按下载量换算68

Gemini CLI

9.58%
按下载量换算33

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills