用例

创建用例 分享链接 /book/api/726.html

作者:王怡栋 最后编辑:宋辰轩 于 2024-09-30 15:22:42 浏览量:9616
POST
/products/id/testcases

创建用例

请求URL

https://xxx.com/api.php/v1/products/id/testcases

请求头

名称 类型 必填 描述
Token String 认证凭证Token

请求体

名称 类型 必填 描述
branch int 所属分支
module int 所属模块
story int 所属需求
title string 用例标题
type string 用例类型(feature 功能测试 | performance 性能测试 | config 配置相关 | install 安装部署 | security 安全相关 | interface 接口测试 | unit 单元测试 | other 其他)
stage string 适用阶段(unittest 单元测试阶段 | feature 功能测试阶段 | intergrate 集成测试阶段 | system 系统测试阶段 | smoke 冒烟测试阶段 | bvt 版本验证阶段)
precondition string 前置条件
pri int 优先级
steps array 用例步骤
  ∟  desc string 步骤
  ∟  expect string 期望
keywords string 关键词

请求示例

{
    "title": "case1",
    "pri": 1,
    "steps": [
        {
            "desc": "步骤1",
            "expect": "结果1"
        }
    ],
    "type": "feature"
}

请求响应

名称 类型 必填 描述
id int 用例ID
product int 所属产品
branch int 所属分支
module int 所属模块
story int 相关需求
storyVersion int 需求版本
title string 需求标题
precondition string 前置条件
pri int 优先级
type string 用例类型(feature 功能测试 | performance 性能测试 | config 配置相关 | install 安装部署 | security 安全相关 | interface 接口测试 | unit 单元测试 | other 其他)
stage string 适用阶段(unittest 单元测试阶段 | feature 功能测试阶段 | intergrate 集成测试阶段 | system 系统测试阶段 | smoke 冒烟测试阶段 | bvt 版本验证阶段)
steps array 用例步骤列表
  ∟  desc string 步骤
  ∟  expect string 期望
fromBug int 来自于Bug
fromCaseID int 来自于用例
openedBy string 创建人
openedDate datetime 创建时间

响应示例

{
    "id": 8,
    "project": 0,
    "product": 1,
    "execution": 0,
    "branch": 0,
    "lib": 0,
    "module": 0,
    "path": 0,
    "story": 0,
    "storyVersion": 1,
    "title": "case1",
    "precondition": "",
    "keywords": "",
    "pri": 1,
    "type": "feature",
    "auto": "no",
    "frame": "",
    "stage": "",
    "howRun": "",
    "scriptedBy": "",
    "scriptedDate": null,
    "scriptStatus": "",
    "scriptLocation": "",
    "status": "normal",
    "subStatus": "",
    "color": "",
    "frequency": "1",
    "order": 0,
    "openedBy": "admin",
    "openedDate": "2021-11-29T07:18:29Z",
    "reviewedBy": "",
    "reviewedDate": null,
    "lastEditedBy": "",
    "lastEditedDate": null,
    "version": 1,
    "linkCase": "",
    "fromBug": 0,
    "fromCaseID": 0,
    "fromCaseVersion": 1,
    "deleted": false,
    "lastRunner": "",
    "lastRunDate": null,
    "lastRunResult": "",
    "toBugs": [],
    "steps": [
        {
            "id": 5,
            "parent": 0,
            "case": 8,
            "version": 1,
            "type": "step",
            "desc": "步骤1",
            "expect": "结果1"
        }
    ],
    "files": [],
    "currentVersion": 1
}
评论列表
🚆
风流倜傥的帽子 2025-03-20 15:51:25 回复
我用postman用这个url创建成功,在页面上看不到对应创建得用例
请求报文:
{
"title": "case1",
"pri": 1,
"steps": [
{
"desc": "步骤1",
"expect": "结果1"
}
],
"type": "feature"
}
响应报文:
{
"id": 9,
"project": 0,
"product": 3,
"execution": 0,
"branch": 0,
"lib": 0,
"module": 0,
"path": 0,
"story": 0,
"storyVersion": 1,
"title": "case1",
"precondition": "",
"keywords": "",
"pri": 1,
"type": "feature",
"auto": "no",
"frame": "",
"stage": "",
"howRun": "",
"script": "",
"scriptedBy": "",
"scriptedDate": null,
"scriptStatus": "",
"scriptLocation": "",
"status": "normal",
"subStatus": "",
"color": "",
"frequency": "1",
"order": 0,
"openedBy": {
"id": 1,
"account": "admin",
"avatar": "",
"realname": "admin"
},
"openedDate": "2025-03-20T07:45:38Z",
"reviewedBy": null,
"reviewedDate": null,
"lastEditedBy": null,
"lastEditedDate": null,
"version": 1,
"linkCase": "",
"fromBug": 0,
"fromCaseID": 0,
"fromCaseVersion": 1,
"deleted": false,
"lastRunner": "",
"lastRunDate": null,
"lastRunResult": "",
"scene": 0,
"sort": 0,
"toBugs": [],
"fromBugData": [],
"linkCaseTitles": [],
"currentVersion": 1,
"files": [],
"steps": [
{
"name": "1",
"id": 2,
"step": "步骤1",
"desc": "步骤1",
"expect": "结果1",
"type": "step",
"parent": 0,
"grade": 1
}
]
}
回复
报文提示用例已经创建成功,可以到接口网址(/products/id/testcases) 中对应id的产品中查看一下是否有这个用例,另外禅道当前版本号是多少?可以升级到最版本21.5版本验证看下。
升级前请做好数据备份
备份请参考文档: http://www.zentao.net/book/zentaopmshelp/42.html
升级请参考文档: http://www.zentao.net/book/zentaopmshelp/41.html
🌆
豁达的鼠标 2024-10-10 15:58:37 回复
请问该接口是否支持批量上传用例,如果支持的格式是怎样的?
回复
官方提供的 restful 类型的接口是不能支持的。
禅道提供另外一种 api 调用方式, 你可以看看这个文章
https://www.zentao.net/book/extension-dev/1341.html
该方法大致分为两个步骤,1鉴权 ,2,模拟浏览器的请求 (请求地址,请求方式,请求参数)

您可以联系客户经理,邀请您加入技术交流群沟通,即时性会更好一些。
回复
请教通过模拟浏览器请求导入用例的方式有用例数的限制嘛
回复
默认是没有限制的,不过取决于网络环境和请求体大小,可能数量过多会导致请求超时,建议根据实际情况选择合适的数据量
🎵
禅道2555 2023-05-22 14:01:42 回复
获取测试用例列表怎么根据模块和每页返回多少条数据查询啊,比如:/products/:id/testcases?模块=160&页数=100
回复
您好,可以添加页面上方的QQ,通过后,邀请您加入技术交流群,协助您解决问题呢。
💐
曹胜 2023-04-20 15:57:28 回复
postman请求404啊
回复
添加上方商务qq,进群沟通下这个问题
丁芝
高级客户经理
17663906485
1481227768
统一服务热线 4006-8899-23
我要提问提问有任何问题,您都可以在这里提问。 问题反馈反馈点击这里,让我们聆听您的建议与反馈。