testzeus-notifications#

Configure notification channels for test results in TestZeus.

Category: integration · Version: 1.0.0 · Requires: testzeus-auth

Triggers: notification, email alert, webhook, slack, jira, alert, notify, channel, notification channel, pagerduty, opsgenie, teams

Overview#

Notification channels in TestZeus allow you to receive alerts when tests complete, suites finish, or reports are generated. Channels can include email addresses, webhooks, and integrations with third-party services.

Quick Reference#

# Email channel
testzeus notification create \
  --name "QA Team" \
  --emails "[email protected],[email protected]"

# Webhook channel
testzeus notification create \
  --name "CI Pipeline" \
  --webhooks "https://ci.example.com/webhook"

# Combined channel
testzeus notification create \
  --name "All Alerts" \
  --emails "[email protected]" \
  --webhooks "https://hooks.example.com"

# List channels
testzeus notification list

# Update
testzeus notification update channel_id \
  --is-default true

# Delete
testzeus notification delete channel_id

Channel Types#

Email Notifications#

# Single email
testzeus notification create \
  --name "Dev Team" \
  --emails "[email protected]"

# Multiple emails
testzeus notification create \
  --name "QA Team" \
  --emails "[email protected],[email protected],[email protected]"

# With default flag
testzeus notification create \
  --name "Default Alerts" \
  --emails "[email protected]" \
  --is-default true

Webhook Notifications#

# Single webhook
testzeus notification create \
  --name "CI Webhook" \
  --webhooks "https://ci.example.com/testzeus/webhook"

# Multiple webhooks
testzeus notification create \
  --name "Multi Pipeline" \
  --webhooks "https://hooks1.example.com,https://hooks2.example.com"

# Slack webhook format
testzeus notification create \
  --name "Slack Alerts" \
  --webhooks "https://hooks.slack.com/services/XXX/YYY/ZZZ"

Third-Party Integrations#

Slack#

# Use Slack incoming webhook URL
testzeus notification create \
  --name "Slack #qa-alerts" \
  --webhooks "https://hooks.slack.com/services/XXX/YYY/ZZZ"

Microsoft Teams#

# Use Teams incoming webhook URL
testzeus notification create \
  --name "Teams QA" \
  --webhooks "https://outlook.office.com/webhook/..."

PagerDuty#

# Use PagerDuty events API endpoint
testzeus notification create \
  --name "PagerDuty" \
  --webhooks "https://events.pagerduty.com/v2/enqueue"

OpsGenie#

# Use OpsGenie webhook URL
testzeus notification create \
  --name "OpsGenie" \
  --webhooks "https://app.opsgenie.com/webhooks/..."

Create Notification Channel#

Basic Email Channel#

testzeus notification create \
  --name "QA Team Alerts" \
  --emails "[email protected]" \
  --is-active true

Webhook Channel#

testzeus notification create \
  --name "CI/CD Integration" \
  --webhooks "https://ci.example.com/webhooks/testzeus" \
  --is-active true

Combined Channel#

testzeus notification create \
  --name "Full Alert Stack" \
  --emails "[email protected],[email protected]" \
  --webhooks "https://hooks.example.com/slack,https://hooks.example.com/teams" \
  --is-active true \
  --is-default true

With Filtering#

Some channels can be filtered to receive only specific alerts:

# Critical alerts only
testzeus notification create \
  --name "Critical Only" \
  --emails "[email protected]" \
  --filters "priority=critical"

Manage Channels#

List Channels#

# List all
testzeus notification list

# Get details
testzeus notification get channel_id

Update Channel#

# Update emails
testzeus notification update channel_id \
  --emails "[email protected],[email protected]"

# Update webhooks
testzeus notification update channel_id \
  --webhooks "https://new-webhook.example.com"

# Enable/disable
testzeus notification update channel_id \
  --is-active false

# Set as default
testzeus notification update channel_id \
  --is-default true

# Remove from default
testzeus notification update channel_id \
  --is-default false

Delete Channel#

testzeus notification delete channel_id

Use with Schedules#

Attach to Report Schedule#

testzeus schedule create \
  --name "Daily Report" \
  --cron-expression "0 9 * * *" \
  --notification-channels channel_id_1,channel_id_2

Attach to Suite Schedule#

testzeus test-suite-schedules create \
  --name "Daily Checkout" \
  --test-suite suite_id \
  --cron-expression "0 9 * * *" \
  --notification-channels channel_id

Webhook Payload#

When a webhook is triggered, it receives a payload like:

{
  "event": "test_run_completed",
  "timestamp": "2024-03-24T10:30:00Z",
  "data": {
    "run_id": "run_123",
    "name": "Checkout Suite",
    "status": "completed",
    "passed": 24,
    "failed": 1,
    "duration": "4m 23s"
  },
  "links": {
    "dashboard": "https://app.testzeus.ai/runs/run_123",
    "report": "https://app.testzeus.ai/runs/run_123/report"
  }
}

Event Types#

Event

Description

test_run_started

A test run began

test_run_completed

A test run finished

test_run_failed

A test run failed

suite_started

A suite run began

suite_completed

A suite run finished

report_generated

A scheduled report was generated

SDK Usage#

from testzeus_sdk import TestZeusClient

async def main():
    async with TestZeusClient() as client:
        # Create email channel
        email_channel = await client.notification_channels.create_notification_channel(
            name="QA Team",
            display_name="QA Team Alerts",
            emails=["[email protected]", "[email protected]"],
            is_active=True
        )
        
        # Create webhook channel
        webhook_channel = await client.notification_channels.create_notification_channel(
            name="CI Pipeline",
            emails=["[email protected]"],
            webhooks=["https://ci.example.com/webhook"],
            is_active=True
        )
        
        # List channels
        channels = await client.notification_channels.get_list()
        
        # Update
        await client.notification_channels.update_notification_channel(
            channel_id,
            is_default=True
        )
        
        # Delete
        await client.notification_channels.delete(channel_id)

Best Practices#

1. Separate Alert Levels#

# Critical failures only - page people
testzeus notification create \
  --name "PagerDuty Critical" \
  --webhooks "https://events.pagerduty.com/..."

# All results - email team
testzeus notification create \
  --name "Team Email" \
  --emails "[email protected]"

# Reports only - leadership
testzeus notification create \
  --name "Weekly Summary" \
  --emails "[email protected]"

2. Use Descriptive Names#

# Good
--name "Slack #qa-alerts"
--name "PagerDuty Production"
--name "Email QA Team"

# Avoid
--name "channel1"
--name "test"
--name "notify"

3. Set Default Channel#

# Only one should be default
testzeus notification update channel_id --is-default true

Common Workflows#

CI/CD Pipeline Integration#

# 1. Create webhook channel
testzeus notification create \
  --name "GitHub Actions" \
  --webhooks "https://github.com/webhooks/testzeus"

# 2. Attach to suite schedule
testzeus test-suite-schedules create \
  --name "CI Checks" \
  --test-suite ci_suite_id \
  --cron-expression "0 * * * *" \
  --notification-channels github_actions_channel_id

On-Call Rotation#

# 1. Create PagerDuty channel
testzeus notification create \
  --name "On-Call" \
  --webhooks "https://events.pagerduty.com/..."

# 2. Attach to critical suites
testzeus test-suite-schedules create \
  --name "Critical Path" \
  --test-suite critical_suite_id \
  --cron-expression "0 9 * * *" \
  --notification-channels oncall_channel_id

Daily Summary#

# 1. Create email channel
testzeus notification create \
  --name "Daily Summary" \
  --emails "[email protected]"

# 2. Attach to report schedule
testzeus schedule create \
  --name "Evening Report" \
  --cron-expression "0 18 * * *" \
  --notification-channels daily_summary_channel_id

Error Handling#

Common Errors#

Error

Cause

Solution

Invalid webhook URL

Malformed URL

Check URL format

Webhook unreachable

URL not accessible

Test webhook endpoint

Email invalid

Malformed email

Check email addresses

Test Webhook#

Always test your webhook before using in production:

# Send test notification (if supported)
curl -X POST https://your-webhook-url \
  -H "Content-Type: application/json" \
  -d '{"event": "test", "message": "Test from TestZeus"}'

Component Schema#

Use NotificationChannel component:

{
  "component": "NotificationChannel",
  "props": {
    "name": "QA Team",
    "type": "email",
    "emails": ["[email protected]"],
    "webhooks": [],
    "isActive": true,
    "isDefault": false
  }
}
{
  "component": "NotificationChannel",
  "props": {
    "name": "CI Webhook",
    "type": "webhook",
    "emails": [],
    "webhooks": ["https://ci.example.com/webhook"],
    "isActive": true,
    "isDefault": true
  }
}