'AI自动化测试平台'
by @yontlly
This skill should be used when developing or using an AI-powered automated testing platform based on LangChain+DeepSeek. It implements intelligent test case...
clawhub install ai-test-platform📖 About This Skill
name: ai-test-platform description: This skill should be used when developing or using an AI-powered automated testing platform based on LangChain+DeepSeek. It implements intelligent test case generation, automated script execution (API/UI), test reporting, and authorization management for internal company use.
AI Test Platform Developer Guide
Purpose
Build an AI-powered automated testing platform for internal company use, leveraging DeepSeek LLM and LangChain framework to achieve intelligent test case generation, automated script creation, and test execution management. The platform focuses on API testing (Pytest+Requests) and UI testing (Playwright) with Docker-based isolation and authorization control.
Technology Stack
| Layer | Technology | Version | Purpose | |-------|-----------|---------|---------| | Frontend | Vue3 | ^3.3.0 | Reactive UI framework | | Frontend UI | Element Plus | ^2.4.0 | UI component library | | State Management | Pinia | ^2.1.0 | Global state management | | Backend | FastAPI | ^0.104.0 | Async web framework | | AI Framework | LangChain | ^0.1.0 | LLM orchestration | | LLM | DeepSeek | API | Core AI capabilities | | API Testing | Pytest | ^7.4.0 | Test framework | | API Reporting | pytest-json-report | ^1.5.0 | JSON report generation | | UI Testing | Playwright | ^1.40.0 | Browser automation | | Database | MySQL | 8.0 | Relational database | | Vector DB | Chroma | ^0.4.0 | Vector retrieval | | Deployment | Docker | Latest | Containerization |
Architecture Overview
System Layers
【Frontend Layer】Vue3 + Element Plus + Pinia
↓ (Polling for progress)
【API Layer】FastAPI + Auth Interceptor
↓
【Business Layer】Auth Management, Test Design, Execution, Reporting
↓
【AI Layer】LangChain + DeepSeek + RAG (Chroma)
↓
【Test Engine Layer】Pytest (API) + Playwright (UI)
↓
【Data Layer】MySQL (Business) + Chroma (Vectors)
Core Modules
1. Authorization Management Module
Permission Types:
all - Full functionalitygenerate - Case/script generation onlyexecute - Script execution onlyEncryption:
"yanghua" + timestamp + "360sb"Authorization Flow:
Request with auth_code → AuthInterceptor → Verify validity/expire/count/permission
→ Pass: Allow access + increment usage count
→ Fail: Return 401/403
Key Services:
AuthCodeService: CRUD, validation, count updatesAuthService: Global request interceptor2. AI Generation Module
Supported Document Formats:
Core Chains:
TestCaseChain: Generate test cases from documentsApiScriptChain: Generate Pytest+Requests scriptsUiScriptChain: Generate Playwright scriptsAI Configuration:
3. API Automation Module
Integration:
pytest.main()pytest-json-reportEnvironment:
requirements.txtScript Features:
4. UI Automation Module
Playwright Configuration:
Capabilities:
5. Test Execution Module
Features:
6. Test Report Module
Auto-generation:
AI Analysis Prompt:
Analyze the following test execution log and identify the failure reason:
{execution_log}Provide:
1. Main failure cause
2. Possible problem location
3. Suggested solution
Keep it concise and highlight key information.
7. System Configuration Module
Configuration Management:
Features:
Database Schema
Core Tables
1. auth_codes - Authorization codes - Fields: id, code(encrypted), permission, expire_time, use_count, max_count, is_active
2. test_cases - Test cases - Fields: id, title, content, type(api/ui), created_by, create_time
3. auto_scripts - Automated scripts - Fields: id, name, content, type(api/ui), status, created_by, create_time, update_time
4. execute_records - Execution records - Fields: id, script_id, auth_code, result(success/fail), log, execute_time, duration
5. test_reports - Test reports - Fields: id, record_id, report_content, file_path, ai_analysis, create_time
6. task_progress - Task progress tracking - Fields: id, task_id, task_type(generate/execute), status, progress, message, result_data
See references/architecture.md for complete SQL definitions.
API Design
Unified Response Format
{
"code": 200,
"msg": "success",
"data": {}
}
Common Parameters
auth_code (required) - Authorization code for all core endpointsCore Endpoints
Authorization:
POST /admin/add_auth - Create authorization codePOST /auth/verify - Verify authorizationGET /auth/list - List authorization codesAI Generation:
POST /generate/case - Generate test casesPOST /generate/api - Generate API scriptsPOST /generate/ui - Generate UI scriptsGET /progress/{task_id} - Get task progressAutomation Management:
POST /script/save - Save scriptGET /script/list - List scriptsGET /script/{id} - Get script detailsTest Execution:
POST /execute/run - Run test scriptGET /execute/record - Get execution recordsReport Management:
GET /report/generate - Generate reportGET /report/export - Export reportSystem Configuration:
GET /system/config - Get system configPOST /system/config - Update system configFrontend Progress Polling
Implementation:
Polling Endpoint:
GET /api/progress/{task_id}
Response
{
"status": "processing|completed|failed",
"progress": 50,
"message": "Generating test cases..."
}
Deployment
Docker Compose Setup
version: '3.8'
services:
mysql:
image: mysql:8.0
environment:
MYSQL_ROOT_PASSWORD: root123
MYSQL_DATABASE: ai_test_platform
volumes:
- mysql_data:/var/lib/mysql
ports:
- "3306:3306" app:
build: .
ports:
- "8000:8000"
depends_on:
- mysql
volumes:
- ./data:/app/data
environment:
- DATABASE_URL=mysql+pymysql://root:root123@mysql:3306/ai_test_platform
- DEEPSEEK_API_KEY=your_api_key
volumes:
mysql_data:
Data Persistence
./data/scripts/./data/reports/./data/screenshots/./data/chroma/When to Use This Skill
Use this skill when:
Usage Guidelines
Backend Development
1. Follow FastAPI best practices 2. Implement async/await for I/O operations 3. Use Pydantic models for request/response validation 4. Implement proper exception handling 5. Add logging for all operationsFrontend Development
1. Use Vue3 Composition API 2. Implement proper state management with Pinia 3. Handle loading and error states 4. Implement progress polling for async operations 5. Follow Element Plus component guidelinesAI Integration
1. Use LangChain for chain orchestration 2. Implement retry logic for API calls 3. Handle timeouts gracefully 4. Cache common responses 5. Monitor API usageSecurity Considerations
Project Structure
ai-test-platform/
├── backend/
│ ├── app/
│ │ ├── api/ # API endpoints
│ │ ├── core/ # Core security and config
│ │ ├── models/ # Database models
│ │ ├── schemas/ # Pydantic schemas
│ │ ├── services/ # Business logic
│ │ │ ├── auth.py # Authorization service
│ │ │ ├── ai.py # AI generation service
│ │ │ ├── execute.py # Execution service
│ │ │ └── report.py # Report service
│ │ └── main.py # FastAPI app
│ ├── tests/ # Test files
│ ├── Dockerfile
│ └── requirements.txt
├── frontend/
│ ├── src/
│ │ ├── components/ # Vue components
│ │ ├── pages/ # Page components
│ │ ├── stores/ # Pinia stores
│ │ ├── api/ # API calls
│ │ └── main.js # Entry point
│ └── package.json
├── data/ # Persistent data
│ ├── scripts/
│ ├── reports/
│ ├── screenshots/
│ └── chroma/
├── docs/ # Documentation
├── scripts/ # Utility scripts
│ ├── generate_auth.py # Auth code generator
│ ├── init_db.py # Database initializer
│ └── setup.sh # Setup script
├── docker-compose.yml
└── README.md
Development Workflow
1. Setup Development Environment
# Clone and setup
git clone
cd ai-test-platformBackend setup
cd backend
python -m venv venv
source venv/bin/activate # or venv\Scripts\activate on Windows
pip install -r requirements.txtFrontend setup
cd ../frontend
npm install
2. Initialize Database
python scripts/init_db.py
3. Generate Authorization Codes
python scripts/generate_auth.py
4. Run Development Server
# Backend
cd backend
uvicorn app.main:app --reloadFrontend
cd frontend
npm run dev
5. Docker Deployment
docker-compose up -d
Reference Documents
references/architecture.md - Complete system architecture and database designreferences/AI 自动化测试平台 需求规格说明书.docx - Original requirementsreferences/AI 自动化测试平台 系统设计说明书.docx - Original system designNext Steps
1. Review architecture documentation in references/architecture.md
2. Set up development environment
3. Initialize database schema
4. Generate authorization codes using provided script
5. Start with core backend services (Auth, AI Generation)
6. Implement frontend components
7. Test end-to-end workflows
8. Deploy using Docker Compose