Generate Automation From Testcases 标志

Generate Automation From Testcases

社区
anhtester
generate-automation-from-testcases

Convert manual test cases into automation scripts autonomously using the 6-step AI-RBT Framework and Codex tools.

概览

发布者anhtester
代码仓库codex-testing-kit
技能名称generate-automation-from-testcases
星标数
34
复刻数
14
附带文件
1
许可协议MIT
链接
  • Markdown 格式的指令

    模型按需加载 SKILL.md 文件,因此只有在请求确实与该技能匹配时才会消耗 Token。

  • 兼容任何大语言模型

    AI 技能采用纯 Markdown,而非特定提供商的代码,因此可搭配 GPT、Claude、Gemini、Grok 或本地模型使用。

  • 1 个附带文件

    模型执行任务时可读取的脚本、模板和参考资料。这些文件为只读文件,绝不会被执行。

  • 开源

    由 anhtester 发布于 GitHub。请在安装前查看技能的源文件。

安装

在 TypingMind 中安装 Generate Automation From Testcases AI 技能,即可搭配任意大语言模型使用;也可以将其放入其他支持读取 SKILL.md 的智能体中。

1

安装到 TypingMind

TypingMind 可直接从 GitHub 文件夹安装技能:读取 SKILL.md,打包资源文件,并将结果保存在本地。

  1. 打开应用,前往“插件 → 技能”。
  2. 选择“从 GitHub 安装”。
  3. 粘贴下方的技能文件夹 URL 并确认。
    https://github.com/anhtester/codex-testing-kit/tree/main/.agents/skills/generate-automation-from-testcases
  4. 请在每个需要使用该技能的聊天中启用它。
依次选择“插件 → 技能 → 添加技能 → 从 GitHub URL 导入”,然后粘贴文件夹 URL 并点击“继续”。
2

安装到其他智能体

任何支持 Agent Skills 格式的智能体都可以使用此技能,只需将文件夹复制到该智能体的技能目录中。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/anhtester/codex-testing-kit.git /tmp/codex-testing-kit
mkdir -p .claude/skills
cp -r /tmp/codex-testing-kit/.agents/skills/generate-automation-from-testcases .claude/skills/generate-automation-from-testcases
复制后,请重启 Claude Code,以加载新技能。

在 TypingMind 中使用此技能

在任意 TypingMind 聊天中启用 Generate Automation From Testcases,后续即可交由模型处理。技能的名称和描述会放在系统提示词中,一旦请求匹配,模型就会自动加载完整指令,无需您手动调用,且在实际使用前不会消耗 Token。

一旦请求与技能匹配,模型就会自动加载 Generate Automation From Testcases。

兼容任何 AI 模型

AI 技能是纯 Markdown 指令,而非特定提供商的代码,因此 Generate Automation From Testcases 不局限于最初适配的模型。只需在 TypingMind 中安装一次,即可搭配 GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 或您自行运行的本地模型使用,全程使用您自己的 API 密钥。

  • 仅在需要时加载

    系统提示词中仅包含技能名称和描述。首次遇到匹配的请求时才会加载完整指令,因此技能未使用时,这些指令不会消耗 Token。

  • 在聊天中切换模型

    技能是指令而非代码,因此切换模型不会导致技能失效,新模型会读取同一个 SKILL.md。

技能指令

这是模型会加载的 SKILL.md 内容。请在安装前阅读,因为技能就是模型将遵循的指令。

Workflow: Sinh Automation Scripts từ Manual Test Cases

BẮT BUỘC (MANDATORY SKILLS): Bạn PHẢI nạp và đọc kỹ nội dung các skills sau trước khi bắt đầu:

  • $qa-automation-engineer (.agents/skills/qa-automation-engineer/SKILL.md) — Quy tắc automation chung + workflow routing
  • $ui-debug-agent (.agents/skills/ui-debug-agent/SKILL.md) — Inspect DOM, thu thập locators
  • $smart-locator-agent (.agents/skills/smart-locator-agent/SKILL.md) — Sinh locator ổn định
  • $test-data-generator (.agents/skills/test-data-generator/SKILL.md) — Sinh test data unique, traceable

Workflow này giúp agent đọc file manual test cases do user cung cấp, tự mở browser inspect UI, thu thập locators thực tế, sinh automation scripts hoàn chỉnh (POM + Test), chạy test và tự sửa lỗi cho đến khi PASS.

⚠️ Nguyên tắc thực thi

  • Vai trò: Agent đóng vai Senior Automation Engineer — tuân thủ Clean Code + POM
  • Tất cả output bằng Tiếng Việt
  • TUYỆT ĐỐI KHÔNG ĐOÁN locator — phải inspect DOM thực tế bằng MCP browser tools
  • Desktop viewport 1920×1080 cho tất cả UI debugging
  • ⚠️ Rule E3 (CRITICAL): Khi test FAIL → tự đọc log → phân tích → sửa code → chạy lại. CẤM hỏi user trong quá trình fix lỗi. Chỉ hỏi khi gặp business rule mâu thuẫn hoặc hết 5 vòng auto-heal
  • Artifact task.md — PHẢI tạo để theo dõi tiến độ 6 bước

Workflow này khác gì $generate-automation-from-ui-flow?

from_testcases (workflow này)from_ui_flow
InputFile manual test cases có cấu trúc (MD/Excel/JSON)Mô tả UI steps bằng lời hoặc chỉ URL
Đã có TC✅ Có sẵn — đọc và convert❌ Chưa có — agent tự khám phá
ApproachĐọc TC → inspect UI verify → sinh codeChạy thật trên browser → thu thập → sinh code

Input cần thu thập

InputCách lấyĐộ ưu tiên
File test cases (MD/Excel/JSON/URL)User cung cấp path hoặc URL⭐ Bắt buộc
URL ứng dụngUser cung cấp hoặc trong TC⭐ Bắt buộc
Credentials (nếu cần login)User cung cấp hoặc dùng fixture sẵnTùy chọn
Tech stackUser chỉ định hoặc detect từ projectTùy chọn

Nếu user chưa cung cấp đủ → hỏi trước khi bắt đầu.

Các bước thực hiện

Bước 1: Khởi tạo, Phân tích & Lên Kế Hoạch (Context & Analysis)

  1. Đọc file test cases do user cung cấp:

    • File local → view_file
    • URL (Google Sheets, Confluence, etc.) → read_url_content
    • Xác định format: Markdown table, Excel, JSON, hoặc free-form text
  2. Parse test cases và trích xuất:

    • Danh sách TC (ID, Title, Steps, Expected Results, Test Data, Priority)
    • Các pages/screens mà TC đi qua
    • Pre-conditions (login, setup data, navigate...)
    • Dependencies giữa các TC (nếu có)
  3. Xác định tech stack (nếu chưa rõ):

    FrameworkNgôn ngữRunnerKhi nào chọn
    PlaywrightTypeScriptPlaywright TestMặc định cho web
    PlaywrightPythonPytestKhi project dùng Python
    SeleniumJavaTestNGKhi user yêu cầu Java
    AppiumJavaTestNGMobile app
  4. Tạo artifact task.md để theo dõi tiến độ:

    markdown
    # Automation Generation Progress
    - [x] Bước 1: Phân tích test cases
    - [ ] Bước 2: Khảo sát UI (MCP Recon)
    - [ ] Bước 3: Thiết kế POM
    - [ ] Bước 4: Chuẩn bị test data
    - [ ] Bước 5: Sinh automation scripts
    - [ ] Bước 6: Chạy test + Auto-heal
    
    ## Test Cases to Automate
    | TC ID | Title | Pages | Priority | Status |
    |---|---|---|---|---|
    | TC01 | Login thành công | LoginPage, DashboardPage | P1 | ⏳ |
    | TC02 | Login sai password | LoginPage | P1 | ⏳ |

Bước 2: Khảo sát UI tự động bằng MCP (Autonomous UI Recon)

  1. Mở browser bằng MCP và navigate theo test case steps:

    browser_navigate → URL ứng dụng
    browser_resize → 1920 × 1080
    browser_wait_for → page load hoàn tất
    browser_snapshot → thu thập DOM
  2. Với mỗi page trong test cases, thực hiện:

    • browser_snapshot → đọc accessibility tree
    • Xác định tất cả elements cần tương tác (inputs, buttons, links, dropdowns...)
    • Thu thập locator tốt nhất cho mỗi element (theo priority trong skill $smart-locator-agent)
    • Verify locator bằng cách thử tương tác (browser_click, browser_type)
  3. Ghi nhận vào bảng Locator Collection:

    PageElementActionPrimary LocatorFallback LocatorVerified
    LoginPageEmail inputTypegetByLabel('Email')#email✅
    LoginPagePassword inputTypegetByLabel('Password')#password✅
    LoginPageLogin buttonClickgetByRole('button', {name: 'Login'})button[type=submit]✅
    DashboardPageWelcome textAssertgetByRole('heading', {name: /Welcome/}).welcome-header✅
  4. Xử lý tình huống:

    Tình huốngCách xử lý
    URL bị chặn / cần VPNThông báo user
    Cần đăng nhậpDùng fixture sẵn có hoặc hỏi user credentials
    Element không tìm thấySnapshot lại → thử locator khác → báo user nếu DOM thay đổi
    CAPTCHA / 2FAThông báo user — không thể automate
    Dynamic content / SPAbrowser_wait_for text cụ thể trước khi snapshot
  5. TUYỆT ĐỐI KHÔNG SUY ĐOÁN selector — mọi locator phải verified trên DOM thực tế.

Bước 3: Thiết kế POM (Page Object Model Architecture)

  1. Xác định danh sách Page classes cần tạo:

    • Mỗi page/screen trong test flow → 1 Page class
    • Xem xét tạo BasePage nếu chưa có trong project
  2. Sinh Page Object classes bằng write_to_file:

    Cấu trúc mỗi Page class:

    - Locators (khai báo ở đầu class — từ Bước 2)
    - Constructor (nhận page/driver instance)
    - Action methods (mô tả hành vi user, không mô tả DOM)
    - Verification methods (kiểm tra state/text sau action)

    Nguyên tắc:

    • Method name mô tả hành vi: login(), fillRegistrationForm(), không phải clickButton()
    • Không hardcode waits — chỉ smart waits
    • Locator lấy từ Bước 2 (đã verify) — KHÔNG ĐOÁN
    • Return this hoặc next page object cho method chaining (nếu phù hợp)
  3. Kiểm tra project structure hiện tại:

    • Nếu project đã có pages/ → sinh file vào đúng thư mục
    • Nếu project mới → tạo structure theo skill $framework-architect
    • Không tạo duplicate — kiểm tra page đã tồn tại chưa trước khi tạo mới

Bước 4: Chuẩn bị Dữ liệu (Test Data Strategy)

  1. Phân tích test data từ test cases:

    • Data nào cần unique per run (email, username, ID) → sinh random + traceable
    • Data nào cố định (URL, config values) → đọc từ env/config
    • Data nào cần nhiều bộ (data-driven) → tạo file external (JSON/YAML)
  2. Sinh test data utilities (dùng skill $test-data-generator):

    Format: <prefix>_<testName>_<timestamp>
    Ví dụ:
    - Email:    auto_login_1712049200@test.com
    - Username: auto_user_1712049200
    - Code:     TC_REG_1712049200
  3. Sensitive data (credentials):

    • Đọc từ env variables hoặc config file
    • KHÔNG hardcode trong test code
    • KHÔNG đọc .env trực tiếp (quy tắc bảo mật)

Bước 5: Sinh Automation Scripts (Test Classes)

  1. Tạo test classes — mỗi test case hoặc nhóm TC liên quan → 1 test file:

    Cấu trúc mỗi test:

    Setup (Arrange):
    - Khởi tạo page objects
    - Chuẩn bị test data
    - Navigate đến trang cần test
    - Login (nếu cần, qua fixture)
    
    Execution (Act):
    - Thực hiện các bước theo test case
    - Gọi methods từ Page Objects
    
    Verification (Assert):
    - Assert kết quả với expected results từ TC
    - Assertion message rõ ràng, dễ debug khi fail
  2. Assertions bắt buộc:

    • Mỗi TC PHẢI có ít nhất 1 assertion
    • Assert message mô tả rõ: "Expected dashboard to show after login"
    • Dùng soft assertions khi cần check nhiều điểm
    • Timeout phù hợp (không để default quá ngắn)
  3. Nguyên tắc code:

    • Không waitForTimeout() / Thread.sleep() — chỉ smart waits
    • Không inline locator trong test — locator trong Page class
    • Import gọn gàng — không unused imports
    • Test independent — không phụ thuộc thứ tự chạy
    • Cleanup/teardown nếu test tạo data

Bước 6: Chạy Thử Nghiệm & Tự Sửa Lỗi (Execution & Auto-Heal — RULE E3)

  1. Chạy test bằng run_command:

    bash
    # Playwright TS
    npx playwright test <test_file> --headed
    
    # Playwright Python
    python -m pytest <test_file> --headed
    
    # Selenium Java
    mvn test -Dtest=<TestClass>
  2. Theo dõi kết quả qua command_status:

    Nếu PASS:

    • Chạy lại 1 lần nữa để confirm stability
    • Cập nhật task.md: TC status → ✅ PASS
    • Cleanup debug logs, commented code

    Nếu FAIL → Vào vòng lặp Auto-Heal:

    WHILE test FAIL (tối đa 5 vòng):
      1. Đọc error log / stack trace → xác định step fail
      2. Phân loại lỗi:
    
         | Lỗi | Hành động |
         |---|---|
         | Element not found | Mở MCP → snapshot → verify/thay locator |
         | Click intercepted | Chờ overlay biến mất → retry click |
         | Timeout | Tăng timeout hoặc thêm wait condition |
         | Assertion fail | Kiểm tra expected value vs actual → cập nhật assertion |
         | Navigation error | Kiểm tra URL, redirect, page load |
         | Test data conflict | Sinh data unique mới |
         | Import/compile error | Sửa import, check class name |
    
      3. Sửa code bằng replace_file_content / multi_replace_file_content
      4. Chạy lại test
      5. Ghi log vào task.md: "Vòng 2: Fix locator XYZ → PASS"
  3. ⚠️ Rule E3 — CẤM HỎI USER khi fix lỗi. Chỉ được hỏi khi:

    • Business logic mâu thuẫn (TC nói A nhưng app hiển thị B)
    • Server/app không accessible
    • Đã hết 5 vòng auto-heal mà vẫn fail
  4. Verify stability — test phải PASS 2 lần liên tiếp:

    bash
    # Playwright
    npx playwright test <test_file> --repeat-each=2 --retries=0

Bước 7: Cleanup & Delivery

  1. Code cleanup (bắt buộc):

    • Xóa console.log() / print() / debug log tạm
    • Xóa locator không còn sử dụng
    • Xóa commented-out code
    • Không còn waitForTimeout() / Thread.sleep()
    • Không còn hardcoded test data (email, password)
    • Import gọn gàng — không unused imports
  2. Cập nhật artifact task.md với kết quả cuối:

    markdown
    ## Kết Quả
    | TC ID | Title | Status | Stability | Ghi chú |
    |---|---|---|---|---|
    | TC01 | Login thành công | ✅ PASS | 2/2 stable | — |
    | TC02 | Login sai password | ✅ PASS | 2/2 stable | — |
    | TC03 | Đăng ký tài khoản | ⚠️ SKIP | — | Cần CAPTCHA |
    
    ## Files Created
    - src/pages/login.page.ts
    - src/pages/dashboard.page.ts
    - src/tests/login.spec.ts
  3. Báo cáo cho user:

    • Tổng: X TC PASS / Y TC FAIL / Z TC SKIP
    • Danh sách files đã tạo/sửa
    • Known issues / limitations
    • Bảng Locator Collection (reference)

Output

  • Artifact task.md — checklist tiến độ + kết quả chạy test
  • Page Object classes — 1 file per page, locators verified từ DOM
  • Test classes — automation scripts hoàn chỉnh, đã PASS stable
  • Test data utilities — generators cho data unique + traceable
  • Bảng Locator Collection — tất cả elements + primary/fallback locators
  • Báo cáo kết quả — PASS/FAIL/SKIP summary

附带文件

技能加载后,模型会按需读取这些文件。它们仅作为可读文件提供,绝不会被执行。

常见问题

Generate Automation From Testcases AI 技能有什么作用?

Convert manual test cases into automation scripts autonomously using the 6-step AI-RBT Framework and Codex tools.

为什么在 TypingMind 中使用 Generate Automation From Testcases?

因为您只需安装一次,就能搭配任何模型使用。Generate Automation From Testcases 采用纯 Markdown 格式,而非特定提供商专用的代码,因此同一技能可用于 GPT-5、Claude、Gemini、Grok 或本地模型。您甚至可以在聊天中途切换模型,而不会影响技能的正常使用。TypingMind 使用您自己的 API 密钥,因此您直接向提供商付费,而不是按席位订阅;您的技能和聊天记录也都保留在您自己的存储空间中。

如何在 TypingMind 中安装 Generate Automation From Testcases?

在 TypingMind 中打开“插件 → 技能 → 从 GitHub 安装”,然后粘贴 https://github.com/anhtester/codex-testing-kit/tree/main/.agents/skills/generate-automation-from-testcases。TypingMind 会读取其中的 SKILL.md,打包相关文件,并将其安装为技能,供您在各个聊天中按需启用。

哪些 AI 模型可以使用 Generate Automation From Testcases?

您在 TypingMind 中连接的任何模型都可以。AI 技能采用纯 Markdown 指令,而非特定提供商专用的代码,因此 GPT、Claude、Gemini、Grok 和本地模型都能在请求匹配时加载此技能。

Generate Automation From Testcases 可以搭配多少个 AI 模型使用?

数量不限。只要模型支持技能,您就可以将它与 Generate Automation From Testcases 搭配使用。GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 等模型都可以通过您自己的 API 密钥接入 TypingMind。

Generate Automation From Testcases AI 技能免费吗?

是的。anhtester 已在 GitHub 上根据 MIT 许可证发布了该技能。您只需向自己的 AI 提供商支付所用 Token 的费用。

什么是 AI 技能?

AI 技能是一组可复用的指令,用于教会 AI 模型完成某项特定任务。它遵循开放的 Agent Skills 格式:包含名称和描述的 SKILL.md 文件,以及模型可能需要的脚本、模板或参考文件。模型仅在您的请求与技能匹配时才会读取这些指令,因此已安装的技能在使用前不会产生任何费用。

AI 技能与插件或 MCP 服务器有何不同?

插件或 MCP 服务器为模型提供可调用的新工具,也就是在某处运行并返回结果的代码。AI 技能则为模型提供知识和流程:如何处理任务、遵循哪些步骤,以及怎样的输出才算优质。技能采用纯 Markdown 格式,因此不需要服务器、API 密钥或运行时环境,并且适用于任何模型。

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇