# 基于DeepSeek等LLM模型的测试用例生成器(知识库增强版)
一个LLM驱动的工具,可基于需求描述生成全面的测试用例,通过RAG(检索增强生成)技术结合领域特定知识和历史测试用例进行增强。

## 功能特点
- 📝 从自然语言需求描述生成测试用例
- 📚 上传PDF文档构建领域特定知识库
- 🔍 自动检索并利用相关知识来提升测试用例质量
- 💾 从历史测试用例中学习,改进未来生成效果
- 🧠 支持基于知识增强和基础测试用例生成
- 📊 基于Streamlit的简单直观用户界面
## 安装方法
1. 克隆代码仓库:
```bash
git clone <仓库地址>
cd testcasegen
```
2. 安装依赖:
```bash
pip install -r requirements.txt
```
3. 在脚本(`rag_test_gen.py`)中配置AI服务API密钥或使用环境变量。
## 使用方法
1. 启动应用:
```bash
streamlit run rag_test_gen.py
```
2. 导航到"知识库管理"选项卡,上传领域特定的PDF文档。
3. 进入"生成测试用例"选项卡,输入您的需求描述。
4. 选择是否使用知识增强,然后点击"生成测试用例"。
5. 查看并导出生成的测试用例。
## 依赖项
- streamlit
- pandas
- sklearn
- PyPDF2
- json_repair
- requests
- uuid
## 知识库增强
该工具使用RAG(检索增强生成)技术来增强测试用例生成:
1. **上传PDF文档**: 系统从PDF文件中提取并分段内容
2. **TF-IDF相似度**: 生成测试用例时,检索最相关的知识片段
3. **上下文注入**: 将检索到的知识和类似的历史测试用例注入AI提示中
4. **增强生成**: AI利用丰富的上下文生成更具领域感知的测试用例
## 示例
对于登录模块需求:
```
需要实现一个登录系统,具有用户名/密码认证、
密码恢复、连续3次失败后账户锁定、
以及记住我功能。
```
该工具将生成涵盖正常和边缘情况的结构化测试用例,
每个用例都包含步骤、预期结果和优先级。
## 数据存储
- 历史测试用例存储在`test_cases.csv`中
- 上传文档的知识片段存储在`knowledge_segments.csv`中
## 许可证
[MIT许可证](LICENSE)
# AI Test Case Generator with Knowledge Enhancement
An AI-powered tool for generating comprehensive test cases from requirement descriptions, enhanced with domain-specific knowledge and historical test cases using RAG (Retrieval-Augmented Generation).

## Features
- 📝 Generate test cases from natural language requirement descriptions
- 📚 Upload PDF documents to build a domain-specific knowledge base
- 🔍 Automatically retrieve and leverage relevant knowledge to enhance test case quality
- 💾 Learn from historical test cases to improve future generations
- 🧠 Support for both knowledge-enhanced and basic test case generation
- 📊 Simple and intuitive user interface with Streamlit
## Installation
1. Clone the repository:
```bash
git clone <repository-url>
cd testcasegen
```
2. Install dependencies:
```bash
pip install -r requirements.txt
```
3. Configure your AI service API key in the script (`rag_test_gen.py`) or use environment variables.
## Usage
1. Start the application:
```bash
streamlit run rag_test_gen.py
```
2. Navigate to the "Knowledge Base Management" tab to upload domain-specific PDF documents.
3. Go to the "Generate Test Cases" tab to enter your requirement description.
4. Choose whether to use knowledge enhancement and click "Generate Test Cases".
5. Review and export the generated test cases.
## Dependencies
- streamlit
- pandas
- sklearn
- PyPDF2
- json_repair
- requests
- uuid
## Knowledge Base Enhancement
This tool uses RAG (Retrieval-Augmented Generation) to enhance test case generation:
1. **Upload PDF documents**: The system extracts and segments content from PDF files
2. **TF-IDF similarity**: When generating test cases, the most relevant knowledge segments are retrieved
3. **Context injection**: The retrieved knowledge and similar historical test cases are injected into the AI prompt
4. **Enhanced generation**: AI generates more domain-aware test cases with the enriched context
## Example
For a login module requirement:
```
Need to implement a login system with username/password authentication,
password recovery, account lockout after 3 failed attempts,
and remember-me functionality.
```
The tool will generate structured test cases covering normal and edge cases,
each with steps, expected results, and priority levels.
## Data Storage
- Historical test cases are stored in `test_cases.csv`
- Knowledge segments from uploaded documents are stored in `knowledge_segments.csv`
## License
[MIT License](LICENSE)
---
没有合适的资源?快使用搜索试试~ 我知道了~
AITester开源项目:基于RAG和DeepSeek技术生成测试用例

共4个文件
py:3个
md:1个

8 下载量 133 浏览量
2025-03-19
19:55:24
上传
评论 1
收藏 13KB ZIP 举报
温馨提示
本系统在此基础上引入知识库增强生成(RAG)技术,通过融合领域文档与历史用例数据,使生成结果更贴合业务场景。 传统AI生成方案存在两大痛点:领域知识缺失大模型无法记忆企业私有文档(如需求规格书、接口文档)历史经验浪费过往测试用例未被有效复用本系统通过轻量化RAG架构(无需向量数据库)实现: PDF文档智能解析 构建领域知识库历史用例语义检索 形成经验复用机制动态增强生成提示词 提升用例专业度
资源推荐
资源详情
资源评论





























收起资源包目录






共 4 条
- 1
资源评论


菜鸟小白的学习分享
- 粉丝: 236
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


最新资源
- PLC四层电梯控制系统设计方案【范文仅供参考】.doc
- rust-ruoyi-Rust资源
- 土地整治项目管理存在的问题及对策建议.docx
- 计算机硬件及网络技术在物联网通信中的应用与研究.docx
- 实验数据处理软件Excel.doc
- 项目管理复习资料.doc
- FIR数字滤波器的设计与matlab实现.ppt
- 网络化趋势对商业银行的影响及其对策.docx
- HeartRateSPO2-硬件开发资源
- C--课程设计(凌世林组)通信录管理程序.doc
- 基于AT89C51单片机的多点温度测量系统方案设计书(2).doc
- 网络课考古发现与探索题库.docx
- C语言研究报告—图书信息管理系统.doc
- 手机项目管理流程.docx
- java课程设计方案报告格式.doc
- 人工智能安全的密码学思考.docx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



安全验证
文档复制为VIP权益,开通VIP直接复制
