一键导入
test-plan-generate-test-file
Generate one complete test file with all functions for assigned test cases, including quality scoring and auto-revision
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Generate one complete test file with all functions for assigned test cases, including quality scoring and auto-revision
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | test-plan-generate-test-file |
| description | Generate one complete test file with all functions for assigned test cases, including quality scoring and auto-revision |
| user-invocable | false |
| context | fork |
| model | opus |
| allowedTools | ["Read","Bash","Skill"] |
Generate a complete test file for test cases assigned to one file from the file_mapping.
Called in parallel by test-plan-case-implement (one sub-agent per file in file_mapping).
IMPORTANT: This sub-agent does NOT write files to their final destination. It:
echo > /tmp/...)Write tool is intentionally excluded from allowedTools. Uses context: fork for clean return.
Parent passes all data via Agent prompt as JSON block:
{
"file_index": 0,
"file_path": "tests/upgrade/test_odh_cli.py",
"test_cases": [
{"test_case_id": "TC-CLI-001", "title": "...", "objective": "...", ...},
{"test_case_id": "TC-CLI-003", ...}
],
"function_names": ["test_tc_cli_001", "test_tc_cli_003_pre_upgrade_readiness"],
"framework": "pytest",
"conventions_file": "/path/to/conventions.md",
"pattern_guide": "...content or null...",
"repo_instructions": "...content or null...",
"common_setup_requirements": [...],
"code_repo_path": "/path/to/repo",
"feature_dir": "/path/to/feature"
}
Parse this JSON from prompt to extract all needed variables.
Extract JSON data block from the Agent prompt. Parse to get:
file_index - Index for temp file namingfile_path - Target file path in code repotest_cases - Array of TC objects for this file (already filtered)function_names - Array of function names for TCsframework - Test framework (pytest, go, jest)conventions_file - Path to conventions filepattern_guide - Pattern guide content (or null)repo_instructions - Repo instructions content (or null)common_setup_requirements - Array of shared preconditionscode_repo_path - Repository pathfeature_dir - Feature directory pathStore test_cases as tcs_for_this_file for use in later steps.
IMPORTANT: When analyzing target repository: Read code files and use grep/bash. Do NOT import target repo dependencies (not in test-plan venv) or use inspect.signature().
Get full file path: <code_repo_path>/<file_path>
If file exists, list existing functions:
(cd $(git -C ${CLAUDE_SKILL_DIR} rev-parse --show-toplevel) && uv run python scripts/list_test_functions.py "$full_file_path")
Returns JSON: {"functions": [{"name": "...", "line": 42, "docstring": "..."}]}
Semantic matching: For each TC and expected function name, check if semantic match exists:
If already-implemented tests found, ask user via AskUserQuestion:
✓ Found {N} already-implemented test(s) in {file_path}:
- TC-API-001: test_notebook_creation (line 42)
Options:
1. Skip them - Only implement missing tests
2. Re-generate - Overwrite existing functions
3. Review - Show me existing code first
Set mode: "create" (new file), "append" (add to existing), or filter out implemented TCs.
If mode == "create" (new file), generate header with:
common_setup_requirements has items used in this file:
For each TC in tcs_for_this_file (sequential):
Generate function code using TC spec + conventions + patterns with this priority:
Function structure:
Decorators/Markers:
Function Signature:
Docstring:
{tc_id}: {objective}TC-API-001: Verify metadata fields match expected schemaImplementation (AAA pattern):
Collect each generated function in functions array.
complete_file = header + "\n\n".join(functions)complete_file = existing_content + "\n\n".join(functions)cat > /tmp/test_file_${file_index}.py << 'PYEOF'
$complete_file
PYEOF
python -m py_compile /tmp/test_file_${file_index}.py 2>&1
If syntax error: Fix once, retry. If still invalid: save as .draft, skip scoring.
For each function, invoke in parallel:
/test-plan-score-test-function \
--test-code-file /tmp/func_${tc_id}.py \
--tc-file <tc_file_path> \
--conventions-file <conventions_file> \
--framework <framework> \
--output-file /tmp/test_scores/${tc_id}_score.md
Parse score, handle verdicts:
MAX REVISIONS: 1 per function
Build metadata JSON and write to persistent location:
# Create results directory
mkdir -p /tmp/test_plan_results
# Build metadata JSON
cat > /tmp/file_metadata_${file_index}.json << EOF
{
"file_index": ${file_index},
"file_path": "${file_path}",
"tc_ids": ${tc_ids_for_file_json},
"functions": ${functions_json},
"quality_summary": ${quality_summary_json},
"draft_files": ${draft_files_json},
"errors": ${errors_json}
}
EOF
# Format and write complete result (reads /tmp/test_file_${file_index}.py, embeds content)
(cd $(git -C ${CLAUDE_SKILL_DIR} rev-parse --show-toplevel) && uv run python scripts/format_file_result.py /tmp/file_metadata_${file_index}.json) > /tmp/test_plan_results/file_${file_index}.json
# Output tiny confirmation (NOT full JSON - keeps context clean)
echo '{"status": "complete", "file_index": '${file_index}', "result_file": "/tmp/test_plan_results/file_'${file_index}'.json"}'
CRITICAL: Output ONLY the tiny confirmation JSON. Do NOT add:
The parent reads the full result from the file. This keeps the return value small (~100 bytes) and avoids polluting parent context.
Clean up temporary work files (keep result file for parent):
# Remove temp work files (parallel-safe - indexed by file_index and unique tc_ids)
rm -f /tmp/test_file_${file_index}.py
rm -f /tmp/file_metadata_${file_index}.json
# Remove per-TC temp files
for tc_id in ${tc_ids_for_file[@]}; do
rm -f /tmp/func_${tc_id}.py
rm -f /tmp/test_scores/${tc_id}_score.md
rm -f /tmp/test_scores/${tc_id}_score_revised.md
done
# DO NOT remove /tmp/test_plan_results/file_${file_index}.json - parent will read it
Why keep result file: Parent needs to read the full result after all sub-agents complete. Parent will cleanup /tmp/test_plan_results/ after reading all files.
CRITICAL: After Step 7b cleanup completes, this sub-agent is DONE. Do NOT output any additional text, summaries, or explanations. The tiny confirmation JSON from Step 7a is the complete return value. The parent skill will read the full result from the file and proceed automatically.
When making code generation decisions, follow this priority:
odh-test-context and Tiger Team guides are both from the Tiger Team - one analyzes repos, one provides framework patterns.
Philosophy: Partial success > total failure.
$ARGUMENTS
Analyze test cases and recommend placement (component repo vs downstream E2E repo). Use for determining where each test should be implemented based on test level, dependencies, and repository capabilities.
Generate executable test automation code from test case specifications with intelligent placement in component or downstream repos. Use after test cases are reviewed to create production-ready pytest code that follows repository conventions.
Generate individual test case files from an existing test plan. Use after test plan approval to generate individual TC specifications with preconditions, steps, and expected results organized by category and priority.
Publish test plan artifacts to GitHub — creates a branch, commits all artifacts, and opens a PR with optional reviewer assignment. Use after test plan review to make artifacts available for team collaboration and formal review feedback.
Cross-reference existing test plan gaps with new analyzer findings and documentation to determine which gaps are resolved and which remain open. Use after adding new documentation to identify what questions have been answered and what's still missing.
Browser-based UI test execution against live ODH/RHOAI clusters. Loads TCs from a GitHub PR or repo folder via ui_prepare.py, executes each via a persistent Playwright browser, and produces a visual HTML report with PASS/FAIL/BLOCKED/INCOMPLETE verdicts and screenshots. Use for verifying UI test cases against live clusters with visual evidence and screenshot capture.