查询用例列表
功能介绍
查询用例列表
调用方法
请参见如何调用API。
URI
POST /GT3KServer/v4/{project_id}/testcases/batch-query
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
project_id |
是 |
String |
参数解释: 项目UUID,项目唯一标识,固定长度32位字符(字母和数字)。获取方式请参见获取项目ID 约束限制: 不涉及 取值范围: 项目uuid应符合如下规则:长度等于32位,包含大小写字母、数字 默认取值: 不涉及 |
请求参数
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
X-Auth-Token |
是 |
String |
参数解释: 用户Token。 通过调用IAM服务获取用户Token接口获取(响应消息头中X-Subject-Token的值)。 约束限制: 必传。 取值范围: 字符串长度不少于1,不超过10万。 默认取值: 不涉及。 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
keyword |
否 |
String |
参数解释: 关键字查询 约束限制: 不涉及 取值范围: 用例名或编号 默认取值: 不涉及 |
exeplatforms |
否 |
Array of strings |
参数解释: 执行平台列表数组 约束限制: 不涉及 取值范围: 不涉及 默认取值: 不涉及 |
own |
否 |
Boolean |
参数解释: 是否是我的 约束限制: 不涉及 取值范围: true:是 false:不是 默认取值: 不涉及 |
useOffset |
否 |
Boolean |
参数解释: 是否使用偏移量方式查询 约束限制: 不涉及 取值范围: true:使用偏移量方式查询 false:不使用偏移量方式查询 默认取值: 不涉及 |
version_uri |
否 |
String |
参数解释: 版本URI 约束限制: 不涉及 取值范围: 11到34位 默认取值: 不涉及 |
case_uris |
否 |
Array of strings |
参数解释: 用例URI集合 约束限制: 不涉及 取值范围: 不涉及 默认取值: 不涉及 |
owner_ids |
否 |
Array of strings |
参数解释: 处理者ID集合 约束限制: 不涉及 取值范围: 不涉及 默认取值: 不涉及 |
status_codes |
否 |
Array of strings |
参数解释: 状态Code集合 约束限制: 不涉及 取值范围: 不涉及 默认取值: 不涉及 |
rank_ids |
否 |
Array of strings |
参数解释: 用例等级ID集合 约束限制: 不涉及 取值范围: 不涉及 默认取值: 不涉及 |
module_ids |
否 |
Array of strings |
参数解释: 模块ID集合 约束限制: 不涉及 取值范围: 0,1,2,3,4 默认取值: 不涉及 |
issue_id |
否 |
String |
参数解释: 需求编号 约束限制: 不涉及 取值范围: 不涉及 默认取值: 不涉及 |
creator_ids |
否 |
Array of strings |
参数解释: 创建者ID集合 约束限制: 不涉及 取值范围: 不涉及 默认取值: 不涉及 |
result_codes |
否 |
Array of strings |
参数解释: 结果Code集合 约束限制: 不涉及 取值范围: 不涉及 默认取值: 不涉及 |
iteration_ids |
否 |
Array of strings |
参数解释: 归属迭代ID集合 约束限制: 不涉及 取值范围: 不涉及 默认取值: 不涉及 |
create_start_time |
否 |
String |
参数解释: 创建开始时间 约束限制: 不涉及 取值范围: 不涉及 默认取值: 不涉及 |
create_end_time |
否 |
String |
参数解释: 创建结束时间 约束限制: 不涉及 取值范围: 不涉及 默认取值: 不涉及 |
associated_issue |
否 |
Boolean |
参数解释: 是否关联需求 约束限制: 不涉及 取值范围: null:不限,false:未关联,true:已关联 默认取值: 不涉及 |
associated_defects |
否 |
Boolean |
参数解释: 是否关联缺陷 约束限制: 不涉及 取值范围: null:不限,false:未关联,true:已关联 默认取值: 不涉及 |
include_sub_issue |
否 |
Boolean |
参数解释: 是否查询子需求关联的用例 约束限制: 不涉及 取值范围: true:查询子需求关联的用例 false:不查询子需求关联的用例 默认取值: true |
include_sub_feature |
否 |
Boolean |
参数解释: 是否查询子目录的用例 约束限制: 不涉及 取值范围: true:查询子目录关联的用例 false:不查询子目录关联的用例 默认取值: true |
label_ids |
否 |
Array of strings |
参数解释: 标签ID集合 约束限制: 不涉及 取值范围: 不涉及 默认取值: 不涉及 |
execute_start_time |
否 |
String |
参数解释: 执行开始时间 约束限制: 不涉及 取值范围: 不涉及 默认取值: 不涉及 |
execute_end_time |
否 |
String |
参数解释: 执行结束时间 约束限制: 不涉及 取值范围: 不涉及 默认取值: 不涉及 |
executor_ids |
否 |
Array of strings |
参数解释: 执行者ID集合 约束限制: 不涉及 取值范围: 不涉及 默认取值: 不涉及 |
test_types |
否 |
Array of strings |
参数解释: 类型 约束限制: 不涉及 取值范围: 不涉及 默认取值: 不涉及 |
is_keyword |
否 |
Boolean |
参数解释: 是否组合关键字 约束限制: 不涉及 取值范围: true:组合关键字 false:不组合关键字 默认取值: 不涉及 |
issue_tree_search |
否 |
Boolean |
参数解释: 是否是需求树点击的查询关联用例 约束限制: 不涉及 取值范围: true:需求树点击查询 false:非需求树点击查询 默认取值: 不涉及 |
service_type |
否 |
Integer |
参数解释: 服务类型 约束限制: 不涉及 取值范围: 不涉及 默认取值: 不涉及 |
service_types |
否 |
Array of integers |
参数解释: 服务类型集合 约束限制: 不涉及 取值范围: 不涉及 默认取值: 不涉及 |
stage_type |
否 |
Integer |
参数解释: 阶段过程 约束限制: 不涉及 取值范围: 2:测试设计,3:测试执行,4:质量报告 默认取值: 不涉及 |
feature_uri |
否 |
String |
参数解释: 目录URI 约束限制: 不涉及 取值范围: 不涉及 默认取值: 不涉及 |
sort_field |
否 |
String |
参数解释: 排序字段 约束限制: 不涉及 取值范围: name|testCaseNumber|status|result|createTime|executeTime|executeDuration|module|iteration 默认取值: 不涉及 |
sort_type |
否 |
String |
参数解释: 排序方式 约束限制: 不涉及 取值范围: DESC|ASC|desc|asc 默认取值: 不涉及 |
page_no |
否 |
Integer |
参数解释: 当前页数 约束限制: 不涉及 取值范围: 1-2000 默认取值: 不涉及 |
page_size |
否 |
Integer |
参数解释: 每页条数 约束限制: 不涉及 取值范围: 1-100 默认取值: 不涉及 |
caseType |
否 |
Integer |
参数解释: 用例类型 约束限制: 不涉及 取值范围: 不涉及 默认取值: 不涉及 |
custom_field_info |
否 |
Array of QueryCustomFieldsInfo objects |
参数解释: 用例自定义字段信息 约束限制: 不涉及 取值范围: 不涉及 默认取值: 不涉及 |
task_uri |
否 |
String |
参数解释: 测试套uri 约束限制: 不涉及 取值范围: 不涉及 默认取值: 不涉及 |
associate_issue_detail |
否 |
Boolean |
参数解释: 是否返回需求具体信息(返回需求名称,需求id) 约束限制: 不涉及 取值范围: true:返回 false:不返回 默认取值: 不涉及 |
not_assign_task |
否 |
Boolean |
参数解释: 查询全量用例或查询未分配测试套的用例 约束限制: 不涉及 取值范围: true:查询未分配测试套的用例 false:查询全量用例 默认取值: 不涉及 |
test_designs |
否 |
Array of booleans |
参数解释: 是否来自测试设计 约束限制: 不涉及 取值范围: null或者[true, false]:不限,[true]:来自测试设计,[false]:否来自测试设计 默认取值: 不涉及 |
review_status |
否 |
Integer |
参数解释: 用例评审状态 约束限制: 不涉及 取值范围: 不涉及 默认取值: 不涉及 |
响应参数
状态码:200
参数 |
参数类型 |
描述 |
---|---|---|
total |
Integer |
参数解释: 符合条件的所有记录数 取值范围: 起始记录数 大于 实际总条数时, 值为0, 分页请求才有此值 |
value |
Array of TestCaseListVo objects |
参数解释: 实际的数据类型:单个对象,集合 或 NULL 取值范围: 不涉及 |
reason |
String |
参数解释: 业务失败的提示内容 取值范围: 不涉及 |
page_size |
Integer |
参数解释: 每页展示条数 取值范围: 不涉及 |
page_no |
Integer |
参数解释: 页码 取值范围: 不涉及 |
has_more |
Boolean |
参数解释: 是否有更多 取值范围: true: 有更多 false: 无更多 |
参数 |
参数类型 |
描述 |
---|---|---|
uri |
String |
参数解释: 用例URI 取值范围: 不涉及 |
name |
String |
参数解释: 用例名称 取值范围: 不涉及 |
owner |
NameAndIdVo object |
参数解释: 处理者 取值范围: 不涉及 |
status |
NameAndIdVo object |
参数解释: 状态 取值范围: 不涉及 |
result |
NameAndIdVo object |
参数解释: 结果 取值范围: 不涉及 |
module |
NameAndIdVo object |
参数解释: 模块 取值范围: 不涉及 |
iteration |
NameAndIdVo object |
参数解释: 迭代 取值范围: 不涉及 |
exeplatform |
String |
参数解释: 执行平台 取值范围: apittest,其他三方执行平台 |
number |
String |
参数解释: 用例编号 取值范围: 不涉及 |
description |
String |
参数解释: 用例描述 取值范围: 不涉及 |
rank_id |
String |
参数解释: 用例描述 取值范围: 0|1|2|3|4 |
feature_uri |
String |
参数解释: 目录URI 取值范围: 不涉及 |
release_dev |
String |
参数解释: 版本号 取值范围: 不涉及 |
is_keyword |
Boolean |
参数解释: 是否组合关键字 取值范围: true: 组合关键字 false:不组合关键字 |
script_url |
String |
参数解释: 脚本路径 取值范围: 不涉及 |
report_url |
String |
参数解释: 实时报告地址 取值范围: 不涉及 |
project_uuid |
String |
参数解释: 项目UUID,项目唯一标识,固定长度32位字符(字母和数字)。获取方式请参见获取项目ID 取值范围: 项目uuid应符合如下规则:长度等于32位,包含大小写字母、数字 |
service_type |
NameAndIdVo object |
参数解释: 服务类型信息 取值范围: 不涉及 |
test_type |
IntegerIdAndNameVo object |
参数解释: 测试类型信息 取值范围: 不涉及 |
create_info |
CreateInfoVo object |
参数解释: 创建信息 取值范围: 不涉及 |
execute_info |
ExecuteInfoVo object |
参数解释: 执行信息 取值范围: 不涉及 |
associate_issue_info |
AssociateIssueInfoVo object |
参数解释: 关联需求信息 取值范围: 不涉及 |
associate_defect_info |
AssociateDefectInfoVo object |
参数解释: 关联缺陷信息 取值范围: 不涉及 |
case_type |
Integer |
参数解释: 用例类型 取值范围: 不涉及 |
labels |
String |
参数解释: 用例标签名称列表 取值范围: 不涉及 |
custom_field_info |
Array of CustomFieldVo objects |
参数解释: 自定义字段信息 取值范围: 不涉及 |
is_test_design |
Boolean |
参数解释: 是否来自测试设计 取值范围: null:不限,false:否来自测试设计,true:来自测试设计 |
last_modified |
Long |
参数解释: 最后修改时间 取值范围: null:不限 |
review_status |
Integer |
参数解释: 用例评审状态 取值范围: null:0至127 |
参数 |
参数类型 |
描述 |
---|---|---|
time |
String |
参数解释: 创建时间 取值范围: 不涉及 |
timestamp |
Long |
参数解释: 创建时间时间戳 取值范围: 不涉及 |
user_id |
String |
参数解释: 用户ID 取值范围: 不涉及 |
user_name |
String |
参数解释: 用户名称 取值范围: 不涉及 |
参数 |
参数类型 |
描述 |
---|---|---|
time |
String |
参数解释: 执行开始时间 取值范围: 不涉及 |
timestamp |
Long |
参数解释: 执行开始时间时间戳 取值范围: 不涉及 |
duration |
String |
参数解释: 执行时长 取值范围: 不涉及 |
user_id |
String |
参数解释: 用户ID 取值范围: 不涉及 |
user_name |
String |
参数解释: 用户名称 取值范围: 不涉及 |
execute_times |
Integer |
参数解释: 执行次数 取值范围: 不涉及 |
参数 |
参数类型 |
描述 |
---|---|---|
associate |
Boolean |
参数解释: 是否已关联 取值范围: true: 已关联 false:未关联 |
issue_id |
String |
参数解释: 需求ID 取值范围: 不涉及 |
tracker_id |
String |
参数解释: 需求类型 取值范围: 不涉及 |
board_id |
String |
参数解释: 工作项层级ID 取值范围: 不涉及 |
tracker_name |
String |
参数解释: 需求类型名称 取值范围: 不涉及 |
参数 |
参数类型 |
描述 |
---|---|---|
associate |
Boolean |
参数解释: 是否已关联 取值范围: true:已关联 false:未关联 |
associate_count |
Integer |
参数解释: 关联缺陷数 取值范围: 不涉及 |
参数 |
参数类型 |
描述 |
---|---|---|
type |
String |
参数解释: 字段类型 取值范围: 单行文本text、多行文本textArea、单选框radio、多选框checkBox、日期date、数字number、单选用户user |
value |
String |
参数解释: 测试用例自定义字段值 取值范围: 不涉及 |
custom_field_param |
String |
参数解释: 项目用例自定义字段入参或者返回参数名称 取值范围: 不涉及 |
user_name |
String |
参数解释: 用户名 取值范围: user类型测试用例自定义字段对应用户名,其它类型字段不返回 |
状态码:400
参数 |
参数类型 |
描述 |
---|---|---|
code |
String |
参数解释: 业务失败的错误码 取值范围: 不涉及 |
reason |
String |
参数解释: 业务失败的提示内容 取值范围: 不涉及 |
状态码:401
参数 |
参数类型 |
描述 |
---|---|---|
code |
String |
参数解释: 业务失败的错误码 取值范围: 不涉及 |
reason |
String |
参数解释: 业务失败的提示内容 取值范围: 不涉及 |
状态码:404
参数 |
参数类型 |
描述 |
---|---|---|
code |
String |
参数解释: 业务失败的错误码 取值范围: 不涉及 |
reason |
String |
参数解释: 业务失败的提示内容 取值范围: 不涉及 |
状态码:500
参数 |
参数类型 |
描述 |
---|---|---|
code |
String |
参数解释: 业务失败的错误码 取值范围: 不涉及 |
reason |
String |
参数解释: 业务失败的提示内容 取值范围: 不涉及 |
请求示例
查询用例列表
post https://{endpoint}/GT3KServer/v4/db186d87a311475f9fb926f0b27c495f/testcases/batch-query { "page_no" : 1, "page_size" : 15, "feature_uri" : "db186d87a311475f9fb926f0b27c495f", "service_type" : -1, "stage_type" : "3", "custom_field_info" : [ ], "version_uri" : "v92t00010e47vi9c" }
响应示例
状态码:200
OK
{ "total" : 1, "value" : [ { "uri" : "v90900010bnhnue6", "name" : "2.2.0.7版本新建用例1111", "owner" : { "id" : "8bca8880d0ef42f8904ce8d8d7ff1958", "name" : "这是一个昵称wtt_apitest" }, "status" : { "id" : "7", "name" : "完成" }, "result" : { "id" : "0", "name" : "成功" }, "module" : { "id" : "210965", "name" : "模块1" }, "iteration" : { "id" : "10326909", "name" : "迭代1" }, "number" : "aFNCFu", "description" : "描述字段", "rank_id" : "2", "feature_uri" : "v90800010bnfikvj", "release_dev" : "基线_版本", "is_keyword" : false, "script_url" : "", "report_url" : "", "project_uuid" : "df1a197e6c564efc98e86826a53bf44e", "service_type" : { "id" : "0", "name" : "手工测试" }, "test_type" : { "id" : 1, "name" : "功能性测试" }, "create_info" : { "time" : "2025-03-28 16:19:10", "timestamp" : 1743149950000, "user_id" : "8bca8880d0ef42f8904ce8d8d7ff1958", "user_name" : "这是一个昵称wtt_apitest" }, "execute_info" : { "time" : "2025-03-28 16:21:13", "timestamp" : 1743150073000, "duration" : "00:00:00.000", "user_id" : "8bca8880d0ef42f8904ce8d8d7ff1958", "user_name" : "这是一个昵称wtt_apitest", "execute_times" : 1 }, "associate_issue_info" : { "associate" : true, "issue_id" : "1396119", "tracker_name" : "Story" }, "associate_defect_info" : { "associate" : false }, "case_type" : 0, "labels" : [ { "uri" : "v90800010bnfm9ll", "region" : "roma-devx-3", "label_name" : "标签1", "resource_type" : "TestCase" } ], "is_test_design" : true, "last_modified" : 1743150296000, "review_status" : 0 } ], "page_size" : 100, "page_no" : 1 }
SDK代码示例
SDK代码示例如下。
Java
查询用例列表
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
package com.huaweicloud.sdk.test; import com.huaweicloud.sdk.core.auth.ICredential; import com.huaweicloud.sdk.core.auth.BasicCredentials; import com.huaweicloud.sdk.core.exception.ConnectionException; import com.huaweicloud.sdk.core.exception.RequestTimeoutException; import com.huaweicloud.sdk.core.exception.ServiceResponseException; import com.huaweicloud.sdk.cloudtest.v1.region.CloudtestRegion; import com.huaweicloud.sdk.cloudtest.v1.*; import com.huaweicloud.sdk.cloudtest.v1.model.*; import java.util.List; import java.util.ArrayList; public class ListAllTestCasesSolution { public static void main(String[] args) { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment String ak = System.getenv("CLOUD_SDK_AK"); String sk = System.getenv("CLOUD_SDK_SK"); ICredential auth = new BasicCredentials() .withAk(ak) .withSk(sk); CloudtestClient client = CloudtestClient.newBuilder() .withCredential(auth) .withRegion(CloudtestRegion.valueOf("<YOUR REGION>")) .build(); ListAllTestCasesRequest request = new ListAllTestCasesRequest(); request.withProjectId("{project_id}"); TestCasesQueryInfo body = new TestCasesQueryInfo(); body.withPageSize(15); body.withPageNo(1); body.withFeatureUri("db186d87a311475f9fb926f0b27c495f"); body.withStageType(3); body.withServiceType(-1); body.withVersionUri("v92t00010e47vi9c"); request.withBody(body); try { ListAllTestCasesResponse response = client.listAllTestCases(request); System.out.println(response.toString()); } catch (ConnectionException e) { e.printStackTrace(); } catch (RequestTimeoutException e) { e.printStackTrace(); } catch (ServiceResponseException e) { e.printStackTrace(); System.out.println(e.getHttpStatusCode()); System.out.println(e.getRequestId()); System.out.println(e.getErrorCode()); System.out.println(e.getErrorMsg()); } } } |
Python
查询用例列表
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkcloudtest.v1.region.cloudtest_region import CloudtestRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkcloudtest.v1 import * if __name__ == "__main__": # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak = os.environ["CLOUD_SDK_AK"] sk = os.environ["CLOUD_SDK_SK"] credentials = BasicCredentials(ak, sk) client = CloudtestClient.new_builder() \ .with_credentials(credentials) \ .with_region(CloudtestRegion.value_of("<YOUR REGION>")) \ .build() try: request = ListAllTestCasesRequest() request.project_id = "{project_id}" request.body = TestCasesQueryInfo( page_size=15, page_no=1, feature_uri="db186d87a311475f9fb926f0b27c495f", stage_type=3, service_type=-1, version_uri="v92t00010e47vi9c" ) response = client.list_all_test_cases(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg) |
Go
查询用例列表
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" cloudtest "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cloudtest/v1" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cloudtest/v1/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cloudtest/v1/region" ) func main() { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak := os.Getenv("CLOUD_SDK_AK") sk := os.Getenv("CLOUD_SDK_SK") auth := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). Build() client := cloudtest.NewCloudtestClient( cloudtest.CloudtestClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.ListAllTestCasesRequest{} request.ProjectId = "{project_id}" pageSizeTestCasesQueryInfo:= int32(15) pageNoTestCasesQueryInfo:= int32(1) featureUriTestCasesQueryInfo:= "db186d87a311475f9fb926f0b27c495f" stageTypeTestCasesQueryInfo:= int32(3) serviceTypeTestCasesQueryInfo:= int32(-1) versionUriTestCasesQueryInfo:= "v92t00010e47vi9c" request.Body = &model.TestCasesQueryInfo{ PageSize: &pageSizeTestCasesQueryInfo, PageNo: &pageNoTestCasesQueryInfo, FeatureUri: &featureUriTestCasesQueryInfo, StageType: &stageTypeTestCasesQueryInfo, ServiceType: &serviceTypeTestCasesQueryInfo, VersionUri: &versionUriTestCasesQueryInfo, } response, err := client.ListAllTestCases(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } } |
更多
更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。
状态码
状态码 |
描述 |
---|---|
200 |
OK |
400 |
Bad Request |
401 |
Unauthorized |
404 |
Not Found |
500 |
Internal Server Error |
错误码
请参见错误码。