Token导航 LogoToken导航TokenDH.com
研究检索操作浏览器github未标认证来源可访问许可证需确认审计通过

testing-knowledge测试知识

Agent Skill

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

总安装

291

周安装

12

GitHub Stars

66

下载量

95
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

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

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

命令行安装

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

skills.shnpx skills
npx skills add https://github.com/dykyi-roman/awesome-claude-code --skill testing-knowledge

简介

聚合测试相关知识点与常见问题解决方案。

  • 适合新手学习或快速查阅测试技术细节。适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。
  • 涵盖主流框架、工具使用技巧与调试方法。
  • 内容来自社区贡献,准确性需交叉验证。
  • testing-knowledge 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

Testing Knowledge Base

Quick reference for PHP testing patterns, principles, and best practices.

Testing Pyramid

        /\
       /  \     Functional (10%)
      /────\    - E2E, browser tests
     /      \   - Slow, fragile
    /────────\  Integration (20%)
   /          \ - DB, HTTP, queues
  /────────────\Unit (70%)
 /              \- Fast, isolated
/________________\- Business logic

Rule: 70% unit, 20% integration, 10% functional. Invert the pyramid = slow, brittle test suite.

AAA Pattern (Arrange-Act-Assert)

public function test_order_calculates_total_with_discount(): void
{
    // Arrange — set up test data
    $order = new Order(OrderId::generate());
    $order->addItem(new Product('Book', Money::EUR(100)));
    $discount = new PercentageDiscount(10);

    // Act — execute the behavior
    $total = $order->calculateTotal($discount);

    // Assert — verify the outcome
    self::assertEquals(Money::EUR(90), $total);
}

Rules:

  • One blank line between sections
  • Single Act per test
  • Assert behavior, not implementation

Naming Conventions

PHPUnit Style

test_{method}_{scenario}_{expected}
ExampleMethodScenarioExpected
test_calculate_total_with_discount_returns_reduced_amountcalculateTotalwith discountreturns reduced amount
test_confirm_when_already_shipped_throws_exceptionconfirmwhen already shippedthrows exception
test_email_with_invalid_format_fails_validationEmail (VO)with invalid formatfails validation

Pest Style

it('calculates total with discount applied')
it('throws exception when confirming shipped order')
it('fails validation for invalid email format')

Test Isolation Principles

DO

  • Fresh fixtures per test
  • Independent test execution (any order)
  • Teardown cleans all state
  • Use in-memory implementations

DON'T

  • Shared mutable state between tests
  • Tests depending on execution order
  • Global variables or singletons
  • Real external services in unit tests

Quick Quality Checklist

RuleCheck
One test = one behaviorSingle assertion group
Test is documentationName reads as specification
No logic in testsNo if/for/while
Fast execution<100ms per unit test
Mock interfaces onlyNever mock VO, Entity, final
≤3 mocks per testMore = design smell
Behavior over implementationTest WHAT, not HOW

DDD Component Testing

ComponentTest FocusMocks Allowed
Value ObjectValidation, equality, immutabilityNone
EntityState transitions, business rulesNone
AggregateInvariants, consistency, eventsNone
Domain ServiceBusiness logic spanning aggregatesRepository (Fake)
Application ServiceOrchestration, transactionsRepository, EventDispatcher
RepositoryCRUD operationsDatabase (SQLite)

PHP 8.4 Test Patterns

Unit Test Template

<?php

declare(strict_types=1);

namespace Tests\Unit\Domain;

use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;

#[Group('unit')]
#[CoversClass(Email::class)]
final class EmailTest extends TestCase
{
    public function test_creates_valid_email(): void
    {
        $email = new Email('user@example.com');

        self::assertSame('user@example.com', $email->value);
    }

    public function test_throws_for_invalid_format(): void
    {
        $this->expectException(InvalidArgumentException::class);

        new Email('invalid');
    }
}

Integration Test Template

<?php

declare(strict_types=1);

namespace Tests\Integration\Infrastructure;

use PHPUnit\Framework\Attributes\Group;
use Tests\DatabaseTestCase;

#[Group('integration')]
final class DoctrineOrderRepositoryTest extends DatabaseTestCase
{
    private OrderRepositoryInterface $repository;

    protected function setUp(): void
    {
        parent::setUp();
        $this->repository = $this->getContainer()->get(OrderRepositoryInterface::class);
    }

    public function test_saves_and_retrieves_order(): void
    {
        // Arrange
        $order = OrderMother::pending();

        // Act
        $this->repository->save($order);
        $found = $this->repository->findById($order->id());

        // Assert
        self::assertNotNull($found);
        self::assertTrue($order->id()->equals($found->id()));
    }
}

Test Doubles Quick Reference

TypePurposeWhen to Use
StubReturns canned answersExternal API responses
MockVerifies interactionsEvent publishing
FakeWorking implementationInMemory repository
SpyRecords callsLogging, notifications

Decision Matrix

Need to verify a call was made?
├── Yes → Mock or Spy
└── No → Need real behavior?
    ├── Yes → Fake
    └── No → Stub

Common Test Smells

SmellDetectionFix
Logic in Testif, for, while in testExtract to helper or parameterize
Mock Overuse>3 mocksRefactor design, use Fakes
Mystery GuestExternal files, hidden dataInline test data or use Builder
Eager TestTests multiple behaviorsSplit into separate tests
Fragile TestBreaks on refactorTest behavior, not implementation

Advanced Testing Patterns

Contract Testing (Pact)

AspectUnit TestIntegration TestContract Test
SpeedFastSlowMedium
ScopeSingle classService + depsAPI boundary
IsolationFullPartialConsumer/Provider
Use caseBusiness logicDB, queuesService-to-service

When to use: Microservices REST APIs, message-based systems, event schema verification.

Load Testing Patterns

PatternDurationLoad ProfileGoal
Smoke1-2 minMinimalVerify script works
Load10-30 minExpected trafficPerformance baseline
Stress10-30 min1.5-2x expectedFind breaking point
Spike5-10 minSudden burstTest auto-scaling
Soak2-8 hoursSustainedFind memory leaks

Chaos Testing (Failure Injection)

FailureHow to InjectWhat It Tests
Network latencySleep in middlewareTimeout handling
Service errorReturn 500 randomlyCircuit breaker
Connection refusedClose portFallback behavior
Slow databaseQuery delayQuery timeout handling

E2E Distributed Testing

StrategyHowTrade-off
Test containersDocker Compose per testIsolated but slow
Shared stagingDedicated environmentFast but interference
Data seedingAPI/DB setup per testControlled but complex
Snapshot restoreDB snapshot before testsFast reset

References

For detailed information, load these reference files:

  • references/unit-testing.md — Unit test patterns and examples
  • references/integration-testing.md — Integration test setup and patterns
  • references/ddd-testing.md — Testing DDD components (VO, Entity, Aggregate, Service)
  • references/advanced-testing.md — Contract testing (Pact), chaos testing, load testing patterns (ramp-up, spike, soak), E2E distributed testing

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

35.31%
按下载量换算34

Claude

28.62%
按下载量换算27

Cursor

18.96%
按下载量换算18

Gemini CLI

8.58%
按下载量换算8

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

操作浏览器

该 Skill 可能涉及浏览器控制能力,使用时可能读取或操作网页内容,需要在受控环境中确认权限边界。

安装前确认

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

来源信息

继续浏览同类 Skills