Skip to content

CC integration: Unit test rules#4323

Draft
stracker-phil wants to merge 1 commit intodev/developfrom
dev/PCP-6288-cc-unit-test-rules
Draft

CC integration: Unit test rules#4323
stracker-phil wants to merge 1 commit intodev/developfrom
dev/PCP-6288-cc-unit-test-rules

Conversation

@stracker-phil
Copy link
Copy Markdown
Collaborator

Description

Adds Claude Code developer tooling to standardize PHP unit test writing across the project.

What's included

  • .claude/agents/unit-test-writer.md: A sub-agent with instructions for writing PHPUnit tests in this codebase. It includes:
    • GIVEN/WHEN/THEN doc blocks on every test method
    • A general naming convention
    • Stub-over-mock preference, with a decision table to justify mocks
    • Data providers with descriptive string keys
    • Required patterns: stateful fixture closures, testable subclasses for protected methods
    • A quality checklist the agent must verify before delivering
    • Relevant DDEV test commands
  • .claude/rules/unit-test-conventions.md: A Claude Code rule scoped to tests/PHPUnit/**/*.php that instructs the assistant to always delegate test writing to the new unit-test-writer agent, never inline.
  • .gitignore update: Adds general support to track relevant claude code files (include all .claude/ content, but exclude all *.local.* files in all folders).

Why

Test quality has been inconsistent - missing doc blocks, mocks where stubs suffice, no data providers, tests asserting implementation details. Routing all test work through a specialized agent with hard-wired conventions prevents regressions in test quality without requiring manual review of every test PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant