with one click
add-integration-test
"
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Menu
"
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Based on SOC occupation classification
"
"
"
"
"
"
| name | add-integration-test |
| description | " |
tests/integration/gather_phase.bats — dispatch mode setup pattern, failure gating teststests/integration/synthesize_phase.bats — synthesis retry, ULTRAINIT_MAX_RETRIES usagetests/integration/resume.bats — state.json phase-completion skip patterntests/helpers/test_helper.bash — _common_setup, make_claude_envelopetests/fixtures/findings/ — all 8 findings fixtures to use in dispatchtouch tests/integration/<phase>_<scenario>.bats
Boilerplate (copy from tests/integration/gather_phase.bats):
#!/usr/bin/env bats
# Integration tests for <phase_function>: <scenario>
setup() {
load '../helpers/test_helper'
_common_setup
load '../helpers/mock_claude'
setup_mock_claude
# Set ULTRAINIT_MAX_RETRIES=1 for any test involving synthesis
# (prevents 30s retry delays in error-path tests)
export ULTRAINIT_MAX_RETRIES=1
}
teardown() {
_common_teardown
}
Dispatch mode (for multi-agent phase tests):
@test "gather_evidence: all agents succeed" {
# Create dispatch responses for all 8 core agents
for agent in identity commands git-forensics patterns tooling docs-scanner security-scan structure-scout; do
make_claude_envelope \
"$(cat "$BATS_TEST_DIRNAME/../fixtures/findings/${agent}.json")" \
"0.15" > "$MOCK_CLAUDE_DISPATCH_DIR/${agent}.json"
done
run gather_evidence
assert_success
assert_file_exists "$WORK_DIR/findings/identity.json"
run jq '.gather' "$WORK_DIR/state.json"
refute_output 'null'
}
Single mode (for synthesis tests):
@test "synthesize: pass 1 writes CLAUDE.md output" {
# Pre-populate all findings that build_docs_context reads
for agent in identity commands git-forensics patterns tooling docs-scanner security-scan structure-scout; do
cp "$BATS_TEST_DIRNAME/../fixtures/findings/${agent}.json" \
"$WORK_DIR/findings/"
done
cp "$BATS_TEST_DIRNAME/../fixtures/developer-answers.json" \
"$WORK_DIR/developer-answers.json"
make_claude_envelope \
"$(cat "$BATS_TEST_DIRNAME/../fixtures/synthesis/output-docs.json")" \
"2.50" > "$MOCK_CLAUDE_RESPONSE"
run synthesize
assert_success
assert_file_exists "$WORK_DIR/synthesis/output-docs.json"
}
@test "gather_evidence: skips when phase already complete" {
# Mark gather complete in state.json
mark_phase_complete "gather"
FORCE=false run gather_evidence
assert_success
# Verify mock was never called
run grep -c 'CALL:' "$MOCK_CLAUDE_LOG"
assert_output "0"
}
Synthesis tests require all findings to exist. Copy fixtures, not raw — dispatch routing needs the three-way identity:
# Correct: copy to $WORK_DIR/findings/ (not synthesis/)
cp "$BATS_TEST_DIRNAME/../fixtures/findings/identity.json" "$WORK_DIR/findings/"
# WRONG: developer-answers.json goes in $WORK_DIR, NOT findings/
cp "$BATS_TEST_DIRNAME/../fixtures/developer-answers.json" "$WORK_DIR/developer-answers.json"
# Phase completion
run is_phase_complete "gather"
assert_success
# Findings file exists and has correct content
assert_file_exists "$WORK_DIR/findings/identity.json"
run jq -e '.name' "$WORK_DIR/findings/identity.json"
assert_success
make test-integration
Check raw output — integration tests run with || true in CI and always show green.
Forgetting make_claude_envelope wrapper — raw fixture JSON causes run_agent to write "null" to findings silently. Every mock response must be envelope-wrapped.
Dispatch name collision — dispatch mode matches by case-insensitive substring of --json-schema basename. If docs.json appears before docs-scanner.json in alphabetical order, the wrong fixture is served. Use more specific names.
Systemic failure threshold math — gather_phase.bats pre-creates exactly 4 of 8 findings to test systemic failure (3+ of 8 failed). If you add a 9th core agent, update this test.