## Tip: Test Iteratively, Not at the End

**Category**: testing

**Problem**: Generating large amounts of code before testing leads to hard-to-debug issues.

**Solution**: Test after each meaningful change, not just at the end.

**Example**:

❌ **Test at End**:
```
1. Generate entire feature (10 files, 500+ lines)
2. Try to run tests
3. 20 tests fail
4. Spend hours debugging
5. Can't isolate which change caused which failure
```

✅ **Test Iteratively**:
```
1. Generate data model → Test
2. Add validation → Test
3. Create API endpoint → Test
4. Add authentication → Test
5. Write integration test → Test

Each step: ~5 minutes of testing, easy to fix issues
```

**Workflow Pattern**:
```
For each component/function:
1. Ask Claude to generate it
2. Review the code
3. Run relevant tests
4. Fix any issues immediately
5. Move to next component
```

**Why It Works**:
- Isolates issues to recent changes
- Faster debugging (smaller surface area)
- Builds confidence incrementally
- Catches integration issues early

**Pro Tip**: Use watch mode for automatic testing:
```bash
# JavaScript
npm run test -- --watch

# Python
pytest-watch

# Go
goconvey
```

**Tags**: #testing #workflow #debugging #claude-code #best-practices
