Token导航 LogoToken导航

Agent Skill · 研究检索

testing-strategies(测试策略)

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

testing-strategies 是研究检索类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为接触敏感数据;许可证信息还不明确,第三方扫描已通过,按安装量在研究检索类的 73,675 个 Skill 里排第 67,317。

总安装 247周安装 10GitHub Stars 3下载 78核验 2026-05-01

安装说明

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

安装方式

通过对话安装

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

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

命令行安装

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

skills.shnpx skills
npx skills add https://github.com/1mangesh1/dev-skills-collection --skill testing-strategies

这个 Skill 是做什么的

研究检索类 Skill 主要解决「找资料、核对事实、把来源整理清楚」的问题,通常会让助手先检索再总结。

适用于测试策略设计与方法论指导,帮助构建合理的测试金字塔结构。核心能力包括单元测试、集成测试和端到端测试的编写与优化建议。使用时需确认项目测试框架、运行命令及夹具数据, 避免为通过测试而破坏真实逻辑。testing-strategies 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

安装方式:github,权限仅限读取仓库内容。

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

上手步骤

4 步
  1. 1

    确认自己的宿主工具

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

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/1mangesh1/dev-skills-collection --skill testin…;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

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

  4. 4

    按最小权限试用

    它需要接触敏感数据,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

testing-strategies 怎么安装?

在终端执行 npx skills add https://github.com/1mangesh1/dev-skills-collection --skill testing-strategi…。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

testing-strategies 支持哪些 AI 工具?

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

testing-strategies 需要什么权限?

权限级别是接触敏感数据。该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

testing-strategies 是免费的吗?

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

testing-strategies 用的人多吗?

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

testing-strategies 安全吗?

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

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

值得选的地方

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

先想清楚的地方

  • 需要接触敏感数据,装到常用环境前要先评估影响面。
  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

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

不太适合

  • 环境里有大量密钥、凭证,不方便给第三方 Skill 读取的人。
  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

研究检索类 Skill 对比

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

寻找技能 · Codex、Claude

31,199,81316,486操作浏览器MIT有提醒
self-improving-agent

自我改进 Agent · OpenClaw

16,464,0023,396接触敏感数据MIT-0通过
soultrace

灵魂追踪 · Codex、Claude

7,588,94412需要联网未明确有提醒
self-improving

自我完善 · OpenClaw

6,829,2841,046需要联网MIT-0通过
microsoft-foundry

微软代工厂 · Codex、Claude

6,614,144764调用外部服务未明确有提醒
testing-strategies

测试策略 · 本页

2473接触敏感数据未明确通过

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

SKILL.md 原文

Testing Strategies and Methodologies

Testing Pyramid

         /  E2E   \          ~5-10% of tests
        / --------- \
       / Integration  \      ~15-25% of tests
      / --------------- \
     /    Unit Tests      \   ~65-80% of tests
    /______________________\

Unit tests form the base. Fast (milliseconds), test a single function or class in isolation. When one fails, it should point to exactly what broke.

Integration tests verify components work together: a service calling a database, two modules interacting, an HTTP handler processing a request through the application. Slower, more setup, but catch issues unit tests cannot.

End-to-end tests simulate real user behavior through the full stack. Slow, expensive to maintain, prone to flakiness. Use sparingly for critical user journeys only.

Inverting the pyramid (many E2E, few unit) leads to slow feedback, flaky CI, and difficult debugging.

Unit Testing Patterns

Arrange-Act-Assert (AAA)

def test_apply_discount_reduces_price_by_percentage():
    # Arrange
    product = Product(name="Widget", price=100.00)
    discount = Discount(percentage=15)
    # Act
    final_price = discount.apply(product)
    # Assert
    assert final_price == 85.00

Given-When-Then

Equivalent to AAA with BDD terminology. Useful when tests map to user stories.

test('registered user with valid credentials receives auth token', () => {
  // Given
  const user = createUser({ email: 'test@example.com', password: 'secure123' });
  // When
  const result = authService.login(user.email, 'secure123');
  // Then
  expect(result.token).toBeDefined();
});

If the test name contains "and", it is likely testing too much.

Mocking Strategies

Types of Test Doubles

Stub: Returns predetermined data. Does not verify how it was called.

Spy: Records calls for later verification. jest.spyOn(logger, 'warn') then assert it was called with expected arguments.

Mock: Pre-programmed with expectations. Fails the test if not called correctly. Created via frameworks like Mockito, unittest.mock, or Jest.

Fake: A working but simplified implementation, such as an in-memory database replacing PostgreSQL.

When to Mock

Mock when the dependency is slow (network, disk I/O), nondeterministic (time, randomness), has side effects (emails, payments), or you need to simulate errors (timeouts, 500s).

Do not mock when the collaborator is a value object, you are testing the integration itself, the mock replicates the dependency's logic, or you are mocking three layers deep.

Over-mocking makes tests pass while the real system is broken. If refactoring breaks twenty mocks, those tests are testing the wrong thing.

Integration Testing

Database Tests

Use a real database, not mocks, for repository and query tests. Roll back transactions after each test or use a fresh schema for isolation.

def test_find_active_users_excludes_deactivated(db_session):
    db_session.add(User(name="Alice", active=True))
    db_session.add(User(name="Bob", active=False))
    db_session.commit()
    result = user_repo.find_active(db_session)
    assert len(result) == 1
    assert result[0].name == "Alice"

Container-Based Testing with Testcontainers

Testcontainers spins up real services (PostgreSQL, Redis, Kafka) in Docker for tests. Available for Java, Python, Node.js, Go,.NET. Eliminates "works on my machine" discrepancies.

API Integration Tests

Test HTTP endpoints with a running server and real or containerized dependencies. Verify both the response and the persisted state.

End-to-End Testing

Test critical user journeys: signup, checkout, payment, core workflows. Do not use E2E for edge cases coverable at lower levels.

Playwright: Multi-browser (Chromium, Firefox, WebKit), multi-language, supports multiple tabs and iframes. Better for cross-browser and complex scenarios.

Cypress: JavaScript only, primarily Chromium-based. Strong DX with time-travel debugging. Better for JS-only teams with simpler needs.

test('user completes purchase', async ({ page }) => {
  await page.goto('/products');
  await page.click('[data-testid="product-add-to-cart"]');
  await page.click('[data-testid="cart-checkout"]');
  await page.fill('[data-testid="card-number"]', '4242424242424242');
  await page.click('[data-testid="place-order"]');
  await expect(page.locator('[data-testid="order-confirmation"]')).toBeVisible();
});

Use data-testid attributes for selectors. Never select by CSS classes or DOM structure.

Test-Driven Development

Red-Green-Refactor

  1. Red: Write a failing test for the next small piece of behavior.
  2. Green: Write the minimum code to pass. No more.
  3. Refactor: Clean up while keeping tests green.

Practical Workflow

Pick the simplest behavior first. Write one test. Run it, confirm it fails for the right reason. Write just enough code. Confirm it passes. Refactor if needed. Repeat.

TDD works best when you resist writing more production code than the current test demands. The discipline is in the small steps.

Property-Based Testing

Generates hundreds of random inputs and checks that invariants hold for all of them.

What it catches that examples miss: off-by-one errors at unexpected boundaries, Unicode handling failures, integer overflow, rare input combinations humans would not think to test.

from hypothesis import given
from hypothesis.strategies import lists, integers

@given(lists(integers()))
def test_sort_preserves_length(xs):
    assert len(sorted(xs)) == len(xs)

@given(lists(integers()))
def test_sort_output_is_ordered(xs):
    result = sorted(xs)
    for i in range(len(result) - 1):
        assert result[i] <= result[i + 1]

In JavaScript, use fast-check for the same approach. Property-based tests complement example-based tests. Use them for pure functions, serialization roundtrips, data transformations, and functions with well-defined invariants.

Snapshot Testing

When useful: Catching unintended changes to serialized output (HTML, JSON, CLI output), guarding generated code against accidental changes.

When harmful: Large snapshots no one reviews, tests that break on every intentional change leading to blind --update usage, snapshots of volatile data (timestamps, random IDs).

Keep snapshots small. If longer than 30-40 lines, assert on specific fields instead.

Test Coverage

Meaningful Coverage vs Vanity Metrics

Line coverage measures execution, not verification. 100% coverage with no assertions proves nothing.

Focus on branch coverage (both sides of conditionals), behavior coverage (every documented behavior verified), and critical path coverage (error handling tested). 80% line coverage is a reasonable floor. Chasing 100% creates low-value tests for trivial code.

Mutation Testing

Modifies production code (changes > to >=, removes lines, swaps booleans) and checks whether tests fail. Surviving mutants indicate undertested code.

Tools: Stryker (JS/TS), PIT (Java), mutmut (Python), cargo-mutants (Rust).

A high mutation score is a stronger quality signal than high line coverage.

API Testing

Contract Testing with Pact

Verifies consumer and provider agree on an API's shape without both services running simultaneously. The consumer generates a contract file; the provider verifies it independently. This decouples service testing in microservice architectures.

Schema Validation

Validate responses against OpenAPI/JSON Schema definitions in tests. This catches drift between documentation and actual behavior.

from jsonschema import validate

def test_users_endpoint_matches_schema(client, user_schema):
    response = client.get('/api/users')
    for user in response.json():
        validate(instance=user, schema=user_schema)

Performance Testing

Load Testing with k6

import http from 'k6/http';
import { check, sleep } from 'k6';

export const options = {
  stages: [
    { duration: '2m', target: 100 },  // ramp up
    { duration: '5m', target: 100 },  // hold
    { duration: '2m', target: 0 },    // ramp down
  ],
};

export default function () {
  const res = http.get('https://api.example.com/products');
  check(res, { 'status is 200': (r) => r.status === 200 });
  sleep(1);
}

Measure response time percentiles (p50, p95, p99) -- not averages. Track throughput, error rate under load, and resource consumption. k6 is scriptable and CI-friendly. Artillery is YAML-configured for quick HTTP/WebSocket load tests.

Testing in CI/CD

Parallel Execution

Split tests across runners using jest --shard, pytest-split, or CI-native parallelism (GitHub Actions matrix, CircleCI). Distribute by timing data to prevent one slow shard from bottlenecking.

Flaky Test Management

Flaky tests erode trust. Quarantine them into non-blocking jobs. Track flake rates (BuildPulse, Datadog Test Visibility). Fix or delete within a defined SLA. Never use retry-and-ignore as a permanent solution.

Test Naming Conventions

Test names should read as behavior specifications.

# [unit]_[scenario]_[expected result]
test_parse_date_with_invalid_format_raises_value_error
test_calculate_shipping_for_oversized_item_applies_surcharge

# should [behavior] when [condition]
should return empty list when no results match
should throw AuthError when token is expired

# given [context] when [action] then [outcome]
given_premium_user_when_applying_coupon_then_discount_is_doubled

The name should tell you what failed without reading the test body.

Test Data Management

Factories generate objects with sensible defaults, allowing override of specific fields. Use factory_boy (Python), FactoryBot (Ruby), or Fishery (TypeScript).

Builders give fine-grained control for complex objects via chained method calls (new OrderBuilder().withCustomer("Alice").withItem("Widget", 2).build()).

Fixtures provide shared setup data. Keep them minimal -- large shared fixtures create hidden coupling. Prefer factories over fixtures; they make each test self-describing and independent.

Anti-Patterns

Testing implementation details: Asserting on internal state, private methods, or exact SQL. Breaks on refactoring without behavior changes.

Brittle selectors: .btn-primary or div > span:nth-child(3) in E2E tests. Use data-testid.

Slow suites: A 30-minute suite will not be run before pushing. Keep unit tests under 5 minutes. Parallelize the rest.

Mocking everything: Tests only verify mock wiring, not real behavior.

Shared mutable state: Tests pass alone but fail together. Each test must set up and tear down its own state.

Ignoring maintenance: Dead tests, commented-out tests, misleading names. Treat test code with production rigor.

What NOT to Test

Trivial code: Getters, setters, constructors with no logic.

Framework internals: ORM SQL generation, router dispatch, React rendering. Framework maintainers test these.

Third-party libraries: Do not verify that JSON.parse or lodash.groupBy works. Test your code that uses them.

Constants: Testing MAX_RETRIES = 3 equals 3 adds nothing. Test the behavior that uses it.

Every test should justify its existence by catching a real class of bugs. Tests that cannot fail, or fail only on harmless refactoring, are noise.

平台分布

Codex

35.78%
按下载量换算28

Claude

29.36%
按下载量换算23

Cursor

20.36%
按下载量换算16

Gemini CLI

10.35%
按下载量换算8

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

接触敏感数据

该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

安装前确认

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

继续浏览同类 Skills