360 Secure SkillHub
360 安全技能中心

Smoke Test Generator

核心功能:生成含鉴权、CRUD、缓存、实时调用、服务集成5类测试的冒烟测试套件,提供结果统计摘要报告,基于生产级框架适配所有HTTP API。典型场景:API部署验证、CI冒烟检查、演示前校验。输入需配置API基础URL,输出结构化测试结果及日志,可快速定位故障根源。

nissan
nissan
热度 67.00
最近更新 2026-05-11 17:28:01
分类:开发依赖:纯提示词应用场景:代码生成 / API 集成 / 自动化脚本 / DevOps

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add smoke-test-generator
Metadata
name
smoke-test-generator
description
Generate comprehensive API smoke test suites — categorised tests for auth, CRUD, integrations, cached vs live endpoints, with summary reporting. Use when validating API deployments, CI smoke checks, or pre-demo verification. Works with any HTTP API.
version
1.0.0
metadata
{"openclaw":{"emoji":"🧪","requires":{"bins":[],"env":[]},"primaryEnv":null,"network":{"outbound":true,"reason":"Sends HTTP requests to the API under test (typically localhost). No external service calls."}}}

Smoke Test Generator

A structured pattern for API smoke testing with categorised test suites and summary reporting. Adapted from a production test suite that verified 34 endpoints across auth, CRUD, cached audio, story generation, ElevenLabs, and Mistral agent APIs.

Test Categories

Category What It Tests Fail =
Auth Login, token validation, protected routes Nothing else works
CRUD Create, read, update, delete operations Data layer broken
Cached Pre-cached content serves correctly Demo will fail
Live Real API calls complete successfully External dependency down
Integration End-to-end workflows across services Pipeline broken

Pattern

import httpx
import asyncio

BASE_URL = "http://localhost:8000"
results = {"pass": 0, "fail": 0, "skip": 0}

async def test(name: str, category: str, fn):
    try:
        await fn()
        results["pass"] += 1
        print(f"  ✅ [{category}] {name}")
    except Exception as e:
        results["fail"] += 1
        print(f"  ❌ [{category}] {name}: {e}")

async def run_smoke_tests():
    async with httpx.AsyncClient(base_url=BASE_URL, timeout=30) as client:
        # Auth
        await test("Login with valid creds", "auth",
            lambda: assert_status(client.post("/login", json={"email": "test@test.com", "password": "test"}), 200))
        
        # CRUD
        await test("Create item", "crud",
            lambda: assert_status(client.post("/api/items", json={"name": "test"}), 201))
        
        # Cached
        await test("Cached content returns 200", "cached",
            lambda: assert_status(client.get("/api/cached/1"), 200))
        
        # Integration
        await test("Full pipeline completes", "integration",
            lambda: assert_status(client.post("/api/pipeline", json={...}), 200))
    
    total = results["pass"] + results["fail"]
    print(f"\n{'='*40}")
    print(f"Results: {results['pass']}/{total} passed")
    if results["fail"] > 0:
        print(f"⚠️ {results['fail']} failures — do not demo!")

Files

  • scripts/smoke_test.py — Example smoke test suite with all categories