Test Case Generator

👤 zhanghengyi1986-afk 📦 v1.0.0 ⭐ 4.5 ⬇️ 667 下載
💻 開發程式設計 免費

📖 技能介紹


name: test-case-gen description: > Generate test cases from requirements, user stories, PRDs, or API docs. Output structured test cases in markdown tables or export to CSV/JSON. Supports equivalence partitioning, boundary value analysis, decision tables, state transition, and exploratory testing heuristics. Use when: (1) writing test cases from requirements, (2) generating test matrix, (3) analyzing edge cases, (4) creating test plans, (5) reviewing test coverage, (6) "寫測試用例", "生成用例", "測試矩陣", "邊界值分析", "等價類劃分". NOT for: executing tests, automation scripting, or bug tracking. metadata: openclaw: emoji: "📝"


Test Case Generator

Generate structured, thorough test cases from various input sources.

When to Use

USE this skill when: - User provides requirements/PRD/user story and needs test cases - "幫我寫測試用例" / "根據需求生成用例" - Analyzing boundary values or equivalence classes - Creating test matrices or decision tables - Reviewing existing test coverage for gaps

DON'T use this skill when: - Running or executing tests → use api-tester or manual execution - Writing automation scripts → use api-tester or coding tools - Tracking bugs → use project management tools

Workflow

Step 1: Analyze Input

Read the provided input (requirements doc, user story, API spec, or verbal description). Identify: - Functional points: What the system should do - Input parameters: All inputs with data types and constraints - Business rules: Conditional logic, validations, permissions - Integration points: External systems, APIs, databases - Non-functional aspects: Performance, security, usability

Step 2: Apply Test Design Techniques

Based on the analysis, apply appropriate techniques:

Technique When to Apply
Equivalence Partitioning Multiple input values with similar behavior
Boundary Value Analysis Numeric ranges, string lengths, date ranges
Decision Table Complex business rules with multiple conditions
State Transition Workflows with status changes (order, ticket, etc.)
Error Guessing Based on common defect patterns
Pairwise/Combinatorial Multiple parameters with interactions

Step 3: Generate Test Cases

Output format (default markdown table):

| ID | Module | Priority | Precondition | Steps | Input Data | Expected Result | Type |
|----|--------|----------|--------------|-------|------------|-----------------|------|
| TC001 | Login | P0 | User registered | 1. Open login page 2. Enter credentials 3. Click login | user: admin, pass: Admin@123 | Login success, redirect to dashboard | Positive |
| TC002 | Login | P0 | User registered | 1. Open login page 2. Enter wrong password 3. Click login | user: admin, pass: wrong | Error: "Invalid credentials" | Negative |

Priority definitions: - P0: Core functionality, blocks release if failed - P1: Important features, should fix before release - P2: Minor features, can defer - P3: Edge cases, nice to have

Type categories: - Positive / Negative / Boundary / Exception / Security / Performance

Step 4: Coverage Analysis

After generating, provide a coverage summary:

📊 Test Coverage Summary
- Total cases: 25
- By priority: P0(8) P1(10) P2(5) P3(2)
- By type: Positive(10) Negative(8) Boundary(4) Security(2) Performance(1)
- Estimated gaps: [list any uncovered areas]

Export Options

When user requests export:

# Save as CSV — write to workspace
# ~/.openclaw/workspace/output/test_cases.csv

# Save as JSON (for TestLink/禪道 import)
# ~/.openclaw/workspace/output/test_cases.json

禪道 CSV Import Format

所屬模組,用例標題,前置條件,步驟,預期,優先順序,用例型別,關鍵詞
/登入模組,正常登入驗證,使用者已註冊,1.開啟登入頁 2.輸入正確賬號密碼 3.點選登入,登入成功跳轉首頁,1,功能測試,登入;正向
<?xml version="1.0" encoding="UTF-8"?>
<testcases>
  <testcase name="正常登入驗證">
    <summary>驗證使用正確賬號密碼能成功登入</summary>
    <preconditions>使用者已註冊</preconditions>
    <steps>
      <step>
        <step_number>1</step_number>
        <actions>開啟登入頁,輸入正確賬號密碼,點選登入</actions>
        <expectedresults>登入成功,跳轉首頁</expectedresults>
      </step>
    </steps>
    <importance>2</importance>
    <execution_type>1</execution_type>
  </testcase>
</testcases>

Tips for Better Test Cases

  • Always include at least one boundary value test per numeric input
  • For every positive case, create at least one corresponding negative case
  • Don't forget null/empty/whitespace inputs
  • Consider concurrent access scenarios for multi-user features
  • Include data format validation (email, phone, ID card, etc.)
  • Test with special characters: <script>alert(1)</script>, ' OR 1=1--, emoji 🔍

Pairwise / Combinatorial Testing

When multiple input parameters interact, use pairwise to reduce combinations:

引數A: [a1, a2, a3]
引數B: [b1, b2]
引數C: [c1, c2, c3]

全組合: 3×2×3 = 18 條
Pairwise: ~9 條(覆蓋所有兩兩組合)

示例輸出:

# 引數A 引數B 引數C
1 a1 b1 c1
2 a1 b2 c2
3 a2 b1 c3
4 a2 b2 c1
5 a3 b1 c2
6 a3 b2 c3
...

適用場景:瀏覽器相容性(瀏覽器×系統×解析度)、表單多欄位組合、配置項測試。

State Transition Testing

For workflow/status-driven features, map out state transitions:

[草稿] --提交--> [待稽核] --通過--> [已釋出]
   |                  |--駁回--> [已駁回] --修改--> [草稿]
   |--刪除--> [已刪除]

7w4.net收錄了海量優質技能外掛。

Generate test cases covering: - 每個狀態: 至少訪問一次 - 每個轉換: 至少觸發一次 - 非法轉換: 驗證不允許的狀態變更(如 已釋出→草稿) - 併發轉換: 兩人同時稽核同一條記錄

🤖 AI 評測

這個 Skill 質量不錯,內容專業詳盡。它能幫助生成規範的測試用例,支援多種輸出格式,使用起來很方便。主要優點是指導清晰、模板實用;不足是缺少對複雜場景(如效能測試)的深入指導。對於需要快速編寫測試用例的使用者來說,這是一個值得嘗試的工具。

📊 多維度評分

適應性4.4
規範性4.3
有效性4.7
可靠性4.4
可信度5

📁 包含檔案 (2 個)

📄 SKILL.md 6.1 KB
📄 _meta.json 132 B