LLM辅助QA自动化管道

一个AI辅助的QA自动化工作流,通过Claude API生成Playwright测试代码,执行测试,分析失败并创建GitHub问题。

  • by ibne86
  • JavaScript
  • 本地部署
  • 更新于
在 GitHub 查看 ibne86/ai-test-agent-mcp

使用说明

🤖 LLM-Assisted QA Automation Pipeline

An AI-assisted pipeline that generates Playwright tests from user stories, executes them, analyzes failures, and creates GitHub issues for valid bugs.


📌 概述

此存储库是 AI驱动的QA自动化工作流程.

它使用:

  • API克劳德 生成Playwright测试代码
  • 剧作家CLI 执行生成的测试
  • API克劳德 分析故障
  • GitHub REST API 为真正的bug制造问题

🏗️ 建筑概览

External user story file
        ↓
scripts/run-agent.js reads the story
        ↓
Claude API generates Playwright test code
        ↓
Generated files are written locally
        ↓
Playwright CLI executes the test
        ↓
Execution report is saved to reports/
        ↓
scripts/analyze-and-create-issue.js sends the result to Claude API
        ↓
Claude decides whether it is a real bug
        ↓
GitHub REST API creates the issue
        ↓
reports/ gets updated

🎯 这个项目展示了什么

  • 阅读用户故事 外部文件
  • 检查UI和构建选择器上下文
  • 用AI生成剧作家测试
  • 使用Playwright CLI在本地运行测试
  • 用AI分析故障
  • 为已确认的错误创建GitHub问题
  • 将输出保存到 reports/

✅ 当前实施状态

能力 状态
外部故事输入 ✅ 是的
用于测试生成的Claude API ✅ 是的
Playwright CLI执行 ✅ 是的
用于故障分析的Claude API ✅ 是的
通过REST API创建GitHub问题 ✅ 是的

🗂️ 关键文件

文件/文件夹 目的
scripts/run-agent.js 编排故事阅读、选择器发现、测试生成、剧作家执行和运行后分析
scripts/inspect-ui.js 检查正在运行的UI并构建 reports/selector-map.json
scripts/analyze-and-create-issue.js 将执行结果发送给Claude,并通过REST API创建GitHub问题
playwright.config.js 剧作家转轮配置
app/ 带有故意登录错误的演示应用程序
prompts/ 代理流的参考提示文件
reports/ 执行和错误分析工件

🐞 演示应用程序中的故意错误

登录应用程序故意不正确。

当前错误

  • 登录成功 要么 邮件 或 密码正确

正确的行为

  • 只有在以下情况下登录才应成功 两者 电子邮件和密码正确

📁 文件夹结构

ai-test-agent/
├─ app/
├─ generated-tests/
├─ pages/
├─ prompts/
├─ reports/
├─ scripts/
├─ .gitignore
├─ package.json
├─ package-lock.json
├─ playwright.config.js
└─ README.md

⚙️ 设置

1.安装依赖项

npm install
npm run install:browsers

2.运行演示应用程序

npm run dev

📥 外部故事输入

故事文件可以保存 存储库外部.

run-agent.js 接受以下任一条件:

  • --story "path-to-file"
  • 或 STORY_FILE
📄 Example story content
As a valid user, I want to log in with correct email and password so that I can access my account.

Valid email: user@example.com
Valid password: Password123

Acceptance criteria:
- valid email + valid password -> login succeeds
- valid email + wrong password -> login fails
- wrong email + valid password -> login fails
- wrong email + wrong password -> login fails

Success is indicated by the message: "Login successful. Welcome back."
Failure is indicated by the message: "Invalid email or password."

🚀 有用的命令

运行主代理流

npm run agent:run -- --story "C:\path\to\your\story.txt"

仅运行UI检查

npm run agent:inspect -- --url "http://127.0.0.1:4173" --out ".\reports\selector-map.json"

仅运行分析和问题创建

npm run agent:analyze -- --story "C:\path\to\your\story.txt" --report ".\reports\execution-result.json"

🧹 清理说明

此存储库在执行过程中生成运行时工件。这些输出通常不受版本控制,占位符除外,例如 reports/.gitkeep.