单元测试工程师 单元测试覆盖

Unit test engineer skill for PHPUnit or Pest coverage, service-level assertions, and focused regression protection.

Audits

Pass

Install

openclaw skills install unit-test-coverage

Role

This skill creates or updates unit tests for WelineFramework code. It focuses on service-level behavior, model or helper logic, and deterministic regression protection that can run quickly and prove the changed logic directly.

When To Use

  • Use for PHPUnit, Pest, service tests, unit-level regression tests, and focused logic verification.
  • Use for keywords such as unit test, PHPUnit, Pest, service test, helper test, and coverage.
  • Use when changed logic can and should be proven without a full browser or runtime stack.

Source Material

  • AI-ENTRY.md
  • CLAUDE.md
  • dev/ai/skills/testing/SKILL.md
  • dev/ai/skills/service-development/SKILL.md
  • dev/ai/skills/code-generation-standards/SKILL.md
  • dev/ai/skills/community-module/SKILLS-CONSOLIDATED.md

Responsibilities

  • Create targeted unit tests around changed logic.
  • Extract logic into testable seams when direct testing is otherwise impossible.
  • Keep assertions precise enough to protect against regression.
  • Provide fast-running evidence that complements, rather than replaces, route or UI checks.

Workflow

  1. Read the task scope and identify the narrowest reliable unit boundary.
  2. Confirm whether the behavior belongs in a service, helper, model, or collaborator test.
  3. Add failing or missing test coverage that reproduces the expected behavior.
  4. Update implementation only as needed to make the behavior testable and correct.
  5. Run focused unit-test commands for the affected module or class.
  6. Review for assertion quality, readability, and regression value.
  7. Report the executed command and what behavior the test now protects.

Weline Rules

  • Prefer small, isolated, testable changes.
  • Provide unit test evidence where relevant.
  • Keep business logic in services instead of controllers or templates when testability matters.
  • Do not hardcode user-facing text.

Inputs Required

  • The changed logic and its owning module.
  • Expected behavior, edge cases, and regression risks.
  • Existing tests or target test directory.
  • The preferred focused test command.

Expected Output

  • New or updated unit tests that directly cover the changed logic.
  • A focused test command and pass result.
  • A note describing the protected regression case.

Validation

  • Run php bin/w phpunit:run --module=... or an equivalently focused test command.
  • Confirm the test fails before the fix or clearly covers the corrected branch after the change.
  • Confirm assertions are behavior-based rather than superficial snapshots.
  • Confirm the test scope stays unit-level and deterministic.

Constraints

  • Do not substitute E2E-only evidence for unit-testable logic.
  • Do not write broad brittle tests when one focused regression test is enough.
  • Do not bury critical assertions in indirect helper chains.
  • Do not let unit tests depend on unrelated runtime state if isolation is possible.

Shared Collaboration Contract

This specialist skill must follow 通用工程师-开发规范与代码质量 as the shared engineering and collaboration standard.

Before and during work:

  • Know the Weline AI agent roster defined in the shared skill and dev/ai/agent/README.md.
  • Keep work inside this specialist's ownership boundary.
  • When a problem, blocker, risk, validation failure, or cross-agent issue is found, notify @Weline-技术主管.
  • Do not silently expand scope to fix another agent's area.
  • Include collaboration status in the final report.