Skip to content

测试用例 (testcase)

测试用例管理,支持获取测试用例列表,支持获取产品/项目/执行下的测试用例、创建测试用例、获取测试用例详情、修改测试用例、删除测试用例

动作概览

SDK 动作说明方法路径
list获取测试用例列表,支持获取产品/项目/执行下的测试用例GET/{scope}/{scopeID}/testcases
create创建测试用例POST/testcases
get获取测试用例详情GET/testcases/{caseID}
update修改测试用例PUT/testcases/{testcasID}
delete删除测试用例DELETE/testcases/{testcasID}

获取测试用例列表,支持获取产品/项目/执行下的测试用例

  • SDK 调用:request("testcase/list", params)
  • HTTP:GET /{scope}/{scopeID}/testcases
  • 动作类型:list

路径参数

参数说明
scope测试用例范围
scopeID范围ID

查询参数

参数类型必填默认值说明
browseTypestringall状态,默认是all
all 全部
wait 未关闭
needconfirm 需求变动
orderBystring排序
id_asc ID 升序
id_desc ID 降序
title_asc 标题 升序
title_desc 标题 降序
status_asc 状态 升序
status_desc 状态 降序
recPerPagenumber每页数量,不超过1000
pageIDnumber页码,从第1页开始

请求体

无请求体。

返回值

  • 返回形态:list
  • 结果字段:testcases
  • 分页字段:pager

SDK 示例

ts
import { request } from 'zentao-api';

const result = await request("testcase/list", {
  "scope": "<string>",
  "scopeID": 1,
  "browseType": "all",
  "orderBy": "id_asc",
  "recPerPage": 1,
  "pageID": 1
});

创建测试用例

  • SDK 调用:request("testcase/create", params)
  • HTTP:POST /testcases
  • 动作类型:create

路径参数

无路径参数。

查询参数

无查询参数。

请求体

请求体必填:是

Schema:

json
{
  "type": "object",
  "properties": {
    "productID": {
      "type": "integer",
      "description": "所属产品",
      "format": "int32"
    },
    "title": {
      "type": "string",
      "description": "用例标题"
    },
    "module": {
      "type": "integer",
      "description": "所属模块",
      "format": "int32"
    },
    "story": {
      "type": "integer",
      "description": "相关需求",
      "format": "int32"
    },
    "pri": {
      "type": "integer",
      "description": "优先级",
      "format": "int32"
    },
    "type": {
      "type": "string",
      "description": "用例类型(unit 单元测试 | interface 接口测试 | feature 功能测试 | install 安装部署 | config 配置相关 | performance 性能测试 | security 安全相关 | other 其他)"
    },
    "precondition": {
      "type": "string",
      "description": "前置条件"
    },
    "steps": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "用例步骤"
    },
    "expects": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "用例步骤期望"
    },
    "stepType": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "用例步骤类型(step 步骤 | group 父级步骤)"
    },
    "project": {
      "type": "integer",
      "description": "所属项目",
      "format": "int32"
    },
    "execution": {
      "type": "integer",
      "description": "所属执行",
      "format": "int32"
    }
  },
  "required": [
    "productID",
    "title"
  ]
}

示例:

json
{
  "productID": 1,
  "title": "<string>",
  "module": 1,
  "story": 1,
  "pri": 1,
  "type": "<string>",
  "precondition": "<string>",
  "steps": [
    "<string>"
  ],
  "expects": [
    "<string>"
  ],
  "stepType": [
    "<string>"
  ],
  "project": 1,
  "execution": 1
}

返回值

  • 返回形态:object

SDK 示例

ts
import { request } from 'zentao-api';

const result = await request("testcase/create", {
  "productID": 1,
  "title": "<string>",
  "module": 1,
  "story": 1,
  "pri": 1,
  "type": "<string>",
  "precondition": "<string>",
  "steps": [
    "<string>"
  ],
  "expects": [
    "<string>"
  ],
  "stepType": [
    "<string>"
  ],
  "project": 1,
  "execution": 1
});

获取测试用例详情

  • SDK 调用:request("testcase/get", params)
  • HTTP:GET /testcases/{caseID}
  • 动作类型:get

路径参数

参数说明
caseID测试用例ID

查询参数

无查询参数。

请求体

无请求体。

返回值

  • 返回形态:object
  • 结果字段:testcase

SDK 示例

ts
import { request } from 'zentao-api';

const result = await request("testcase/get", {
  "caseID": 1
});

修改测试用例

  • SDK 调用:request("testcase/update", params)
  • HTTP:PUT /testcases/{testcasID}
  • 动作类型:update

路径参数

参数说明
testcasID测试用例ID

查询参数

无查询参数。

请求体

请求体必填:是

Schema:

json
{
  "type": "object",
  "properties": {
    "title": {
      "type": "string",
      "description": "用例标题"
    },
    "moudule": {
      "type": "integer",
      "description": "所属模块",
      "format": "int32"
    },
    "story": {
      "type": "integer",
      "description": "相关需求",
      "format": "int32"
    },
    "pri": {
      "type": "integer",
      "description": "优先级",
      "format": "int32"
    },
    "type": {
      "type": "string",
      "description": "用例类型(unit 单元测试 | interface 接口测试 | feature 功能测试 | install 安装部署 | config 配置相关 | performance 性能测试 | security 安全相关 | other 其他)"
    },
    "precondition": {
      "type": "string",
      "description": "前置条件"
    },
    "steps": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "用例步骤"
    },
    "expects": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "用例步骤期望"
    },
    "stepType": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "用例步骤类型(step 步骤 | group 父级步骤)"
    }
  },
  "required": [
    "title"
  ]
}

示例:

json
{
  "title": "<string>",
  "moudule": 1,
  "story": 1,
  "pri": 1,
  "type": "<string>",
  "precondition": "<string>",
  "steps": [
    "<string>"
  ],
  "expects": [
    "<string>"
  ],
  "stepType": [
    "<string>"
  ]
}

返回值

  • 返回形态:object

SDK 示例

ts
import { request } from 'zentao-api';

const result = await request("testcase/update", {
  "testcasID": 1,
  "title": "<string>",
  "moudule": 1,
  "story": 1,
  "pri": 1,
  "type": "<string>",
  "precondition": "<string>",
  "steps": [
    "<string>"
  ],
  "expects": [
    "<string>"
  ],
  "stepType": [
    "<string>"
  ]
});

删除测试用例

  • SDK 调用:request("testcase/delete", params)
  • HTTP:DELETE /testcases/{testcasID}
  • 动作类型:delete

路径参数

参数说明
testcasID测试用例ID

查询参数

无查询参数。

请求体

无请求体。

返回值

  • 返回形态:text

SDK 示例

ts
import { request } from 'zentao-api';

const result = await request("testcase/delete", {
  "testcasID": 1
});

Released under the MIT License.