From 3acf6fcba87029a07e99cb75b7fefb738217a1cc Mon Sep 17 00:00:00 2001 From: catlog22 Date: Mon, 24 Nov 2025 21:14:32 +0800 Subject: [PATCH] docs: enhance test task generation documentation with existing test infrastructure and framework usage --- .claude/agents/action-planning-agent.md | 45 +++++++++++++++++++ .../workflow/tools/test-task-generate.md | 14 ++++-- 2 files changed, 56 insertions(+), 3 deletions(-) diff --git a/.claude/agents/action-planning-agent.md b/.claude/agents/action-planning-agent.md index f2d12cab..b8e68c53 100644 --- a/.claude/agents/action-planning-agent.md +++ b/.claude/agents/action-planning-agent.md @@ -236,6 +236,25 @@ Generate individual `.task/IMPL-*.json` files with the following structure: - `agent`: Assigned agent for execution - `execution_group`: Parallelization group ID (tasks with same ID can run concurrently) or `null` for sequential tasks +**Test Task Extensions** (for type="test-gen" or type="test-fix"): + +```json +{ + "meta": { + "type": "test-gen|test-fix", + "agent": "@code-developer|@test-fix-agent", + "test_framework": "jest|vitest|pytest|junit|mocha", + "coverage_target": "80%", + "use_codex": true|false + } +} +``` + +**Test-Specific Fields**: +- `test_framework`: Existing test framework from project (required for test tasks) +- `coverage_target`: Target code coverage percentage (optional) +- `use_codex`: Whether to use Codex for automated fixes in test-fix tasks (optional, default: false) + #### Context Object ```json @@ -307,6 +326,32 @@ Generate individual `.task/IMPL-*.json` files with the following structure: } ``` +**Test Task Extensions** (for type="test-gen" or type="test-fix"): + +```json +{ + "flow_control": { + "pre_analysis": [...], + "implementation_approach": [...], + "target_files": [...], + "reusable_test_tools": [ + "tests/helpers/testUtils.ts", + "tests/fixtures/mockData.ts", + "tests/setup/testSetup.ts" + ], + "test_commands": { + "run_tests": "npm test", + "run_coverage": "npm test -- --coverage", + "run_specific": "npm test -- {test_file}" + } + } +} +``` + +**Test-Specific Fields**: +- `reusable_test_tools`: List of existing test utility files to reuse (helpers, fixtures, mocks) +- `test_commands`: Test execution commands from project config (package.json, pytest.ini) + ##### Pre-Analysis Patterns **Dynamic Step Selection Guidelines**: diff --git a/.claude/commands/workflow/tools/test-task-generate.md b/.claude/commands/workflow/tools/test-task-generate.md index 5d8985f2..d95c7491 100644 --- a/.claude/commands/workflow/tools/test-task-generate.md +++ b/.claude/commands/workflow/tools/test-task-generate.md @@ -20,6 +20,7 @@ Generate test planning documents (IMPL_PLAN.md, test task JSONs, TODO_LIST.md) u - **Memory-First**: Reuse loaded documents from conversation memory - **MCP-Enhanced**: Use MCP tools for test pattern research and analysis - **Path Clarity**: All `focus_paths` prefer absolute paths (e.g., `D:\\project\\src\\module`), or clear relative paths from project root +- **Leverage Existing Test Infrastructure**: Prioritize using established testing frameworks and tools present in the project ## Test-Specific Execution Modes @@ -79,7 +80,9 @@ Generate test planning documents (IMPL_PLAN.md, task JSONs, TODO_LIST.md) for te IMPORTANT: This is TEST PLANNING ONLY - you are generating planning documents, NOT executing tests. -CRITICAL: Follow the progressive loading strategy defined in your agent specification (load context incrementally from memory-first approach) +CRITICAL: +- Use existing test frameworks and utilities from the project +- Follow the progressive loading strategy defined in your agent specification (load context incrementally from memory-first approach) ## AGENT CONFIGURATION REFERENCE All test task generation rules, schemas, and quality standards are defined in your agent specification: @@ -124,6 +127,7 @@ Task Configuration: IMPL-001 (Test Generation): - meta.type: "test-gen" - meta.agent: "@code-developer" (agent-mode) OR CLI execution (cli-execute-mode) + - meta.test_framework: Specify existing framework (e.g., "jest", "vitest", "pytest") - flow_control: Test generation strategy from TEST_ANALYSIS_RESULTS.md IMPL-002+ (Test Execution & Fix): @@ -144,7 +148,9 @@ Required flow_control fields: ### TEST_ANALYSIS_RESULTS.md Mapping PRIMARY requirements source - extract and map to task JSONs: - - Test framework config → meta.test_framework + - Test framework config → meta.test_framework (use existing framework from project) + - Existing test utilities → flow_control.reusable_test_tools (discovered test helpers, fixtures, mocks) + - Test runner commands → flow_control.test_commands (from package.json or pytest config) - Coverage targets → meta.coverage_target - Test requirements → context.requirements (quantified with explicit counts) - Test generation strategy → IMPL-001 flow_control.implementation_approach @@ -154,6 +160,7 @@ PRIMARY requirements source - extract and map to task JSONs: 1. Test Task JSON Files (.task/IMPL-*.json) - 6-field schema with quantified requirements from TEST_ANALYSIS_RESULTS.md - Test-specific metadata: type, agent, use_codex, test_framework, coverage_target + - flow_control includes: reusable_test_tools, test_commands (from project config) - Artifact references from test-context-package.json - Absolute paths in context.files_to_test @@ -172,7 +179,8 @@ PRIMARY requirements source - extract and map to task JSONs: Hard Constraints: - Task count: minimum 2, maximum 12 - All requirements quantified from TEST_ANALYSIS_RESULTS.md - - Test framework configuration validated + - Test framework matches existing project framework + - flow_control includes reusable_test_tools and test_commands from project - use_codex flag correctly set in IMPL-002+ tasks - Absolute paths for all focus_paths - Acceptance criteria include verification commands