wordpress仿站流程,网站整站模板下载工具,网站条形码如何做,网站建设标语工具作用#xff1a;
根据输入的功能点#xff0c;生成通用测试点 实现步骤
工具实现主要分2个步骤#xff1a;
1.https请求调用Gpt,将返回响应结果保存为.md文件
2.用python实现 将 .md文件转换成.xmind文件
3.写个简单的前端页面#xff0c;调用上述步骤接口 详细代…工具作用
根据输入的功能点生成通用测试点 实现步骤
工具实现主要分2个步骤
1.https请求调用Gpt,将返回响应结果保存为.md文件
2.用python实现 将 .md文件转换成.xmind文件
3.写个简单的前端页面调用上述步骤接口 详细代码
1.调用gpt请求生成 md文件
import os
import requests
import json测试数据路径管理
SCRIPTS_DIR os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
DATAS_DIR os.path.join(SCRIPTS_DIR, datas)
Testcase_md os.path.join(DATAS_DIR,testcase.md)示例代码def sendGpt_getmd(content):# 设置请求头中的tokenheaders {Content-Type: application/json}# payload 设置请求主体中的参数和数据根据请求的参数格式传参即可payload {参数: 参数值}# 发送POST请求response requests.post(https://xxxxx, headersheaders,datajson.dumps(payload))# 解析响应结果if response.status_code 200:result response.textprint(result)with open(Testcase_md, w, encodingutf-8) as f:f.write(result)else:print(请求失败)if __name__ __main__:# 示例用法:keydes为功能标题casecontentTemp为发送给gpt的模板话术在使用时可以将keydes设置为变量由前端传参。另外可以根据需要修改casecontentTemp内容# 仅包含一级标题二级标题无序列表格式的Markdown形式该格式不可修改因为后续需要以Markdown格式转换成xmind文件keydes上传附件casecontentTemp仅包含一级标题二级标题无序列表格式的Markdown形式发送给我。请写出 一级标题为keydes的测试用例包含功能测试正向/逆向/异常场景性能测试安全测试兼容测试sendGpt_getmd(casecontentTemp)2.将md文件转换成xmind文件
通过步骤1生成了md文件以下代码是将md文件转换成xmind文件
import markdown
from bs4 import BeautifulSoup
import xminddef md_to_xmind(md_file, xmind_file):# 读取MD文件with open(md_file, r, encodingutf-8) as f:md f.read()# 解析MD文件html markdown.markdown(md)# 创建XMind文件workbook xmind.load(xmind_file)# 获取根节点root_topic workbook.getPrimarySheet().getRootTopic()# 递归添加节点def add_topic(parent_topic, node):# 添加节点topic parent_topic.addSubTopic()title node.get(title, )topic.setTitle(title)# 添加文本if html in node:topic.setPlainNotes(node[html])# 递归添加子节点if children in node:for child in node[children]:add_topic(topic, child)# 解析HTML并添加节点soup BeautifulSoup(html, html.parser)rootmap_node {children: []}root_node Nonecurrent_node Nonefor tag in soup.children:if tag.name h1:# 创建根节点root_node {title: tag.string, children: []}current_node root_nodeelif tag.name h2:new_node {title: tag.string, children: []}root_node[children].append(new_node)current_node new_nodeelif tag.name p:current_node[html] str(tag)elif tag.name ul:for li in tag.children:text li.text.strip()if len(text) 0:li_node {title: text, children: []}current_node[children].append(li_node)elif tag.name ol:for li in tag.children:text li.text.strip()if len(text) 0:li_node {title: text, children: []}current_node[children].append(li_node)# 添加节点for node in root_node[children]:add_topic(root_topic, node)# 修改根节点的名称root_topic.setTitle(root_node[title])# 保存XMind文件xmind.save(workbook, xmind_file)if __name__ __main__:# 示例用法 example.md为步骤1生成的文件通过md_to_xmind方法调用将.md文件转换成xmind文件md_to_xmind(example.md, example.xmind) 3.合并步骤1,2后运行
import os
from scripts.datas.mdtoxmind import md_to_xmind
from scripts.datas.sendGpt import sendGpt_getmd测试数据路径管理
SCRIPTS_DIR os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
DATAS_DIR os.path.join(SCRIPTS_DIR, datas)
Testcase_md os.path.join(DATAS_DIR,testcase.md)
Testcase_xmind os.path.join(DATAS_DIR,testcase.xmind)def oneTocase(keydes):casecontentTemp仅包含一级标题二级标题无序列表格式的Markdown形式发送给我。请写出 一级标题为keydes的测试用例包含功能测试正向/逆向/异常场景性能测试安全测试兼容测试sendGpt_getmd(casecontentTemp)md_to_xmind(Testcase_md, Testcase_xmind)if __name__ __main__:# 示例用法keydes上传附件oneTocase(keydes)运行后结果
生成对应文件 打开后查看如下内容 后期集成测试工具构思
1.将详细代码中步骤3暴露出rest接口供前端调用
2.前端页面可提供出形成 通用工具