Commit-Based Testing
Automatically generate and run tests when you commit code.
Enable Commit Testing
VS Code Extension
- Settings (
Cmd+,
) → Search "DebuggAI" - Enable "Commit Testing"
- Set "Test Generation": Automatic
Configuration
settings.json
{
"debuggAI.commitTesting": true,
"debuggAI.autoGenerate": true,
"debuggAI.testOnPush": true
}
How It Works
1. AI Analyzes Changes
When you commit, AI reviews:
- Modified files
- Added components
- Changed functionality
- Removed features
2. Generates Relevant Tests
AI creates tests like:
- "Test new signup validation logic"
- "Test updated checkout flow"
- "Test removed feature doesn't break existing flows"
3. Runs Tests Automatically
- Tests execute against localhost
- Results appear in VS Code
- Failed tests block push (optional)
Smart Test Generation
Component Changes
// Modified: components/LoginForm.tsx
// AI generates: "Test login form with new validation rules"
Route Changes
// Added: pages/checkout/success.tsx
// AI generates: "Test checkout success page displays correctly"
API Changes
// Modified: api/auth/login.ts
// AI generates: "Test login API with updated authentication flow"
Configuration Options
Test Triggers
settings.json
{
"debuggAI.commitTesting": true, // Test on commit
"debuggAI.testOnPush": false, // Test on push
"debuggAI.testOnPR": true, // Test on pull request
"debuggAI.testScheduled": "daily" // Scheduled tests
}
Test Scope
settings.json
{
"debuggAI.testScope": "changed", // Only test changed areas
"debuggAI.fullSuite": false, // Run full test suite
"debuggAI.criticalOnly": true // Only critical path tests
}
Blocking Behavior
settings.json
{
"debuggAI.blockOnFailure": true, // Block push if tests fail
"debuggAI.requireApproval": false, // Manual approval for tests
"debuggAI.retryFailures": 2 // Auto-retry failed tests
}
Git Integration
Pre-commit Hook
Automatically runs tests before commit:
.git/hooks/pre-commit
#!/bin/sh
# Run DebuggAI tests before commit
npx @debugg-ai/cli test --commit
Pre-push Hook
Block pushes if tests fail:
.git/hooks/pre-push
#!/bin/sh
# Verify tests pass before push
npx @debugg-ai/cli verify --exit-on-failure
GitHub Actions Integration
.github/workflows/debuggai.yml
name: DebuggAI Tests
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run DebuggAI Tests
env:
DEBUGGAI_API_KEY: ${{ secrets.DEBUGGAI_API_KEY }}
run: |
npm install
npm run dev &
npx @debugg-ai/cli test --wait-for-server
Team Workflows
Code Review Integration
- Tests auto-run on PR creation
- Results appear in PR comments
- Block merge on test failures
- Team notifications on issues
Branch Protection
branch-protection.json
{
"required_status_checks": {
"strict": true,
"contexts": ["debuggai/tests"]
},
"enforce_admins": true,
"required_pull_request_reviews": {
"required_approving_review_count": 1
}
}
Advanced Patterns
Feature Branch Testing
# Test feature branch against main
git checkout feature/new-auth
npx @debugg-ai/cli test --compare-branch main
Release Testing
# Comprehensive tests before release
git checkout release/v2.0
npx @debugg-ai/cli test --full-suite --critical-path
Hotfix Testing
# Quick critical tests for hotfixes
git checkout hotfix/login-bug
npx @debugg-ai/cli test --critical-only --fast
Monitoring & Alerts
Slack Integration
Configure through VS Code extension settings:
- Slack Webhook URL: Add in DebuggAI extension settings
- Channel: Specify notification channel
- Alert Types: Choose when to notify (failures, successes, etc.)
Email Alerts
Set up through debugg.ai dashboard:
- Team Settings → Notifications
- Add email addresses for test result notifications
- Configure alert frequency and failure thresholds
Performance Optimization
Parallel Testing
settings.json
{
"debuggAI.parallelTests": 3, // Run 3 tests simultaneously
"debuggAI.testTimeout": 30000, // 30 second timeout
"debuggAI.smartRetry": true // Intelligent retry logic
}
Test Caching
settings.json
{
"debuggAI.cacheResults": true, // Cache test results
"debuggAI.skipUnchanged": true, // Skip tests for unchanged code
"debuggAI.incrementalTesting": true // Only test affected areas
}
Troubleshooting
Tests Not Triggering
- Check commit testing is enabled
- Verify git hooks are installed
- Ensure localhost is running
- Check API key is valid
Performance Issues
- Reduce parallel test count
- Enable test caching
- Use incremental testing
- Increase timeout values
False Positives
- Review test descriptions
- Update test patterns
- Add test exclusions
- Report to AI training
Team Adoption
- Start with optional testing
- Gradually enable blocking
- Train team on test descriptions
- Monitor and adjust settings