---
description: Create integration tests within task constraints
argument-hint: "[task-id]"
agent: orchestrator
---

# Task-Bounded Integration Test: $ARGUMENTS

## Phase 0: Task Validation (MANDATORY)

### Check Task Exists

!`TASK_DIR="@backlog/tasks/$ARGUMENTS"`
!`if [ ! -d "$TASK_DIR" ]; then echo "ERROR: Task $ARGUMENTS not found. Use /task-with-spec first"; exit 1; fi`

### Load Integration Test Requirements

!`echo "=== INTEGRATION TEST BOUNDARIES ==="`
!`grep -A 10 "Scope:" "$TASK_DIR/prd.md"`
!`grep -A 15 "Constraints:" "$TASK_DIR/spec.md"`
!`grep -A 10 "Testing Notes:" "$TASK_DIR/spec.md"`

## Phase 1: Task-Context Module Analysis

### Analyze Only Task-Relevant Modules

**Module Focus:** [From task PRD goal]
**Integration Points:** [From task spec architecture]
**Test Requirements:** [From task spec testing notes]

### Task-Bounded Module Discovery:

```
@build Analyze module for task $ARGUMENTS integration testing

ANTI-HALLUCINATION ANALYSIS REQUIREMENTS:
1. Read $TASK_DIR/prd.md and $TASK_DIR/spec.md FIRST
2. Analyze only modules mentioned in task scope
3. Identify only integration points from task architecture
4. Design tests only for task success criteria
5. Follow testing approach from task spec
6. Stop if analysis exceeds task boundaries
7. Document in $TASK_DIR/review.md
8. Mark task success criteria as completed

INTEGRATION TEST BOUNDARIES:
- Module: [From task PRD scope]
- Integration Points: [From task spec architecture]
- Testing Approach: [From task spec testing notes]
- Success Criteria: [From task PRD]

NO EXCEPTIONS: Integration tests must serve task requirements only
```

### Module Analysis (Task-Aligned):

- **Task modules**: [From PRD scope]
- **Integration points**: [From spec architecture]
- **Dependencies**: [From spec constraints]
- **Test framework**: [From spec testing notes]

## Phase 2: Task-Focused Test Strategy

### Test Only Task Requirements

**Test Scope:** [Limited to task success criteria]
**Test Boundaries:** [From task PRD scope]
**Test Constraints:** [From task spec constraints]

### Task-Bounded Test Strategy:

```
Integration Test Strategy for Task $ARGUMENTS

**Integration Points (From Task Spec):**
- [List only integration points from task architecture]
- [Test only task-relevant dependencies]
- [Mock only task-specified external services]

**Test Scope (Task-Only):**
- Unit tests: [If specified in task testing notes]
- Integration tests: [For task module interactions only]
- End-to-end tests: [For task user workflows only]

**Test Requirements (From Task Spec):**
- Framework: [From task testing notes]
- Coverage: [From task success criteria]
- Performance: [From task constraints]
```

## Phase 3: Task-Test Implementation

### Create Tests Within Task Constraints

**Test Implementation Rules:**

- Use test framework from task spec
- Mock only task-specified dependencies
- Test only task integration points
- Follow task testing approach
- Validate against task success criteria

### Test Implementation Process:

```
@build Implement integration tests for task $ARGUMENTS

ANTI-HALLUCINATION IMPLEMENTATION:
1. Continuously validate against $TASK_DIR/prd.md
2. Follow testing approach from $TASK_DIR/spec.md
3. Test only integration points from task architecture
4. Use only allowed test frameworks from spec
5. Mock only dependencies specified in task
6. Stop if any constraint violation detected
7. Complete $TASK_DIR/review.md after work
8. Mark success criteria as completed

TASK CONSTRAINTS:
- Scope: [From PRD scope]
- Architecture: [From spec architecture]
- Testing: [From spec testing notes]
- Success: [From PRD success criteria]

NO EXCEPTIONS: Tests must serve task requirements only
```

## Phase 4: Task Test Validation

### Multi-Agent Quality Assurance (Task-Focused)

```
session({
  mode: "message",
  agent: "code-auditor",
  text: "Review integration tests for task $ARGUMENTS compliance with PRD+spec constraints"
})
```

### Validation Criteria (Task-Aligned):

- **Test coverage**: Meets task success criteria
- **Integration points**: All task architecture points tested
- **Framework compliance**: Uses task-specified testing approach
- **Constraint adherence**: Follows all task constraints

## Phase 5: Task Test Documentation

### Update Task Review

!`cat >> "$TASK_DIR/review.md" << EOF

## Integration Testing - $(date '+%Y-%m-%d')

### Task Context

**Module**: [From task PRD scope]
**Integration Points**: [From task spec architecture]
**Testing Requirements**: [From task spec testing notes]

### Test Implementation

[Integration tests created within task constraints]

### Test Compliance

- Scope compliance: [How tests respect task boundaries]
- Framework adherence: [How tests follow spec approach]
- Success criteria: [How tests achieve task goals]

### Test Results

[Results of task integration testing]

EOF`

### Complete Task

!`/complete-task $ARGUMENTS`

---

**ANTI-HALLUCINATION: Integration tests must serve task constraints, not general testing**
