更新时间:2025-07-24 GMT+08:00
分享

查询用例修改历史记录

功能介绍

查询用例修改历史记录

调用方法

请参见如何调用API

URI

POST /v1/{project_id}/testcases/{testcase_id}/histories/batch-query

表1 路径参数

参数

是否必选

参数类型

描述

project_id

String

参数解释

项目UUID,项目唯一标识,固定长度32位字符(字母和数字)。获取方式请参见获取项目ID

约束限制

不涉及

取值范围

32个字符组成的字符串

默认取值

不涉及

testcase_id

String

参数解释:

用例uri,测试用例唯一标识,长度11-34位字符(字母和数字)。

约束限制:

长度11-34位字符(字母和数字)

取值范围:

不涉及

默认取值:

不涉及

请求参数

表2 请求Header参数

参数

是否必选

参数类型

描述

X-Auth-Token

String

参数解释

用户Token。通过调用IAM服务获取用户Token接口获取(响应消息头中X-Subject-Token的值)

约束限制

不涉及

取值范围

字符串长度不少于1,不超过100000

默认取值

不涉及

表3 请求Body参数

参数

是否必选

参数类型

描述

offset

Integer

参数解释:

起始偏移量,表示从此偏移量开始查询,offset大于等于0,小于等于20000

约束限制:

大于等于0,小于等于20000

取值范围:

大于等于0,小于等于20000

默认取值:

不涉及

limit

Integer

参数解释:

每页显示的条目数量,最大支持200条

约束限制:

大于等于0,小于等于200

取值范围:

大于等于0,小于等于200

默认取值:

不涉及

version_id

String

参数解释:

版本ID(分支ID或测试计划ID),长度11-34位字符(字母和数字)。

约束限制:

长度11-34位字符(字母和数字)

取值范围:

长度11-34位字符(字母和数字)

默认取值:

不涉及

响应参数

状态码:200

表4 响应Body参数

参数

参数类型

描述

total

Integer

参数解释:

起始记录数 大于 实际总条数时, 值为0, 分页请求才有此值

取值范围:

不涉及

values

Array of ExternalTestCaseHistoryVo objects

参数解释:

实际的数据类型:单个对象,集合 或 NULL

取值范围:

不涉及

表5 ExternalTestCaseHistoryVo

参数

参数类型

描述

author

String

参数解释:

资源历史记录创建人ID

取值范围:

不涉及

region

String

参数解释:

逻辑region

取值范围:

不涉及

changes

Array of ResourceChangeExternalVo objects

参数解释:

历史记录字段变更列表

取值范围:

不涉及

id

String

参数解释:

历史记录id

取值范围:

不涉及

testcase_id

String

参数解释:

用例uri,长度11-34位字符(字母和数字)。

取值范围:

长度11-34位字符(字母和数字)

creation_date

String

参数解释:

创建时间

取值范围:

不涉及

create_date_timestamp

Long

参数解释:

创建时间时间戳

取值范围:

不涉及

author_name

String

参数解释:

创建人名称

取值范围:

不涉及

project_id

String

参数解释:

项目UUID,项目唯一标识,固定长度32位字符(字母和数字)。获取方式请参见获取项目ID

取值范围:

长度32位字符(字母和数字)

表6 ResourceChangeExternalVo

参数

参数类型

描述

field_name

String

参数解释:

变更字段

取值范围:

不涉及

custom_field_type

String

参数解释:

测试用例自定义字段类型

取值范围:

不涉及

old_change_info

ElementResourceChangeExternalVo object

参数解释:

变更前的数据信息

取值范围:

不涉及

new_change_info

ElementResourceChangeExternalVo object

参数解释:

变更后的数据信息

取值范围:

不涉及

表7 ElementResourceChangeExternalVo

参数

参数类型

描述

tracker_name

String

参数解释:

工作项类型

取值范围:

不涉及

value

String

参数解释:

取值范围:

不涉及

key

String

参数解释:

key

取值范围:

不涉及

object_value

Object

参数解释:

对象值

取值范围:

不涉及

object_key

Object

参数解释:

对象key

取值范围:

不涉及

tracker_names

Object

参数解释:

缺陷类型

取值范围:

不涉及

board_info

Array of objects

参数解释:

归属看板信息,用例关联工作项信息使用

取值范围:

不涉及

状态码:400

表8 响应Body参数

参数

参数类型

描述

error_code

String

参数解释

接口调用失败错误码

取值范围

不涉及

error_msg

String

参数解释

接口调用失败错误信息

取值范围

不涉及

状态码:401

表9 响应Body参数

参数

参数类型

描述

error_code

String

参数解释

接口调用失败错误码

取值范围

不涉及

error_msg

String

参数解释

接口调用失败错误信息

取值范围

不涉及

状态码:404

表10 响应Body参数

参数

参数类型

描述

error_code

String

参数解释

接口调用失败错误码

取值范围

不涉及

error_msg

String

参数解释

接口调用失败错误信息

取值范围

不涉及

状态码:500

表11 响应Body参数

参数

参数类型

描述

error_code

String

参数解释

接口调用失败错误码

取值范围

不涉及

error_msg

String

参数解释

接口调用失败错误信息

取值范围

不涉及

请求示例

查询用例修改历史记录

post https://{endpoint}/v1/efdb403066474ab08836b9eeaaa23bca/testcases/u4joiwueroiysx/histories/batch-query

{
  "offset" : 0,
  "limit" : 10,
  "version_id" : "932opbuaarweqf"
}

响应示例

状态码:200

查询成功。示例1:获取用例历史记录基础示例。示例2:获取用例历史记录,目录(cataName)、状态(statusName)、等级(rank)、处理人(owner)、迭代(versionName)、模块(moduleName)、版本号(releaseDev)、缺陷(defectId)、需求(issueId)、测试步骤(steps)、描述(description)、预置条件(preparation)均有变更的返回示例。

  • 示例 1

    {
      "total" : 1,
      "values" : [ {
        "author" : "10001",
        "region" : "szv",
        "changes" : [ {
          "field_name" : "name",
          "custom_field_type" : "text",
          "old_change_info" : {
            "tracker_name" : "AR",
            "value" : "aaaaa",
            "key" : "ddddd",
            "object_value" : { },
            "object_key" : { },
            "tracker_names" : { },
            "board_info" : [ { } ]
          },
          "new_change_info" : {
            "tracker_name" : "AR",
            "value" : "aaaaa",
            "key" : "ddddd",
            "object_value" : { },
            "object_key" : { },
            "tracker_names" : { },
            "board_info" : [ { } ]
          }
        } ],
        "id" : "001s90u5o2d1",
        "testcase_id" : "001s16gt6q5",
        "creation_date" : "2022-11-09 16:37:24",
        "create_date_timestamp" : 1660617231016,
        "author_name" : "名称",
        "project_id" : "p45e51b060f1b4e82916f9d2c33e8eb28"
      } ]
    }
  • 示例 2

    {
      "total" : 1,
      "values" : [ {
        "author" : "10001",
        "region" : "szv",
        "changes" : [ {
          "field_name" : "cataName",
          "old_change_info" : {
            "value" : "222",
            "key" : "v9080000upm45j32"
          },
          "new_change_info" : {
            "value" : "新增子目录(1)",
            "key" : "v9040000u4e90spg"
          }
        }, {
          "field_name" : "statusName",
          "old_change_info" : {
            "value" : "测试中",
            "key" : "6"
          },
          "new_change_info" : {
            "value" : "设计中",
            "key" : "5"
          }
        }, {
          "field_name" : "rank",
          "old_change_info" : {
            "value" : "P2",
            "key" : "2"
          },
          "new_change_info" : {
            "value" : "P1",
            "key" : "1"
          }
        }, {
          "field_name" : "owner",
          "old_change_info" : {
            "value" : "Anna",
            "key" : "2053b1fb30fadwad2a4120ac1569870"
          },
          "new_change_info" : {
            "value" : "Bob",
            "key" : "2053b1fb30fd434686a4120ac1569870"
          }
        }, {
          "field_name" : "versionName",
          "old_change_info" : {
            "value" : "迭代1",
            "key" : "26016449"
          },
          "new_change_info" : {
            "value" : "迭代3",
            "key" : "26016459"
          }
        }, {
          "field_name" : "moduleName",
          "old_change_info" : {
            "value" : "功能1-子功能1",
            "key" : "752015"
          },
          "new_change_info" : {
            "value" : "功能2-子功能1",
            "key" : "752017"
          }
        }, {
          "field_name" : "releaseDev",
          "old_change_info" : {
            "value" : "2.0.0.1",
            "key" : "2.0.0.1"
          },
          "new_change_info" : {
            "value" : "1.0.0",
            "key" : "1.0.0"
          }
        }, {
          "field_name" : "defectId",
          "old_change_info" : {
            "key" : "7213756,7213755",
            "object_value" : [ "功能自动化关联缺陷", "不关联的bug" ],
            "object_key" : [ "7213756", "7213755" ],
            "tracker_names" : [ "Bug", "Bug" ],
            "board_info" : [ ]
          },
          "new_change_info" : {
            "key" : "7213751,7213750,7213756,7213755",
            "object_value" : [ "缺陷1", "用例关联的缺陷", "功能自动化关联缺陷", "不关联的bug" ],
            "object_key" : [ "7213751", "7213750", "7213756", "7213755" ],
            "tracker_names" : [ "Bug", "Bug", "Bug", "Bug" ],
            "board_info" : [ ]
          }
        }, {
          "field_name" : "issueId",
          "old_change_info" : {
            "tracker_name" : "Story",
            "value" : "1",
            "key" : "7289959",
            "board_info" : [ ]
          },
          "new_change_info" : {
            "tracker_name" : "Story",
            "value" : "3",
            "key" : "7289957",
            "board_info" : [ ]
          }
        }, {
          "field_name" : "steps",
          "old_change_info" : {
            "object_value" : [ {
              "expect_output" : "",
              "test_step" : ""
            } ]
          },
          "new_change_info" : {
            "object_value" : [ {
              "expect_output" : "<p>awda</p>",
              "test_step" : "<p>awd</p>"
            }, {
              "expect_output" : "<p>dawdaw</p>",
              "test_step" : "<p>awd</p>"
            } ]
          }
        }, {
          "field_name" : "name",
          "old_change_info" : {
            "value" : "ces10"
          },
          "new_change_info" : {
            "value" : "ces10123"
          }
        }, {
          "field_name" : "description",
          "old_change_info" : {
            "value" : "awda"
          },
          "new_change_info" : {
            "value" : "awdawawdawdwdawdadwa"
          }
        }, {
          "field_name" : "preparation",
          "old_change_info" : {
            "value" : "awdaw"
          },
          "new_change_info" : {
            "value" : "awdawaawwwadd"
          }
        } ],
        "id" : "001s90u5o2d1",
        "testcase_id" : "001s16gt6q5",
        "creation_date" : "2022-11-09 16:37:24",
        "create_date_timestamp" : 1660617231016,
        "author_name" : "名称",
        "project_id" : "p45e51b060f1b4e82916f9d2c33e8eb28"
      } ]
    }

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
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.*;


public class ListTestCaseHistoriesSolution {

    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();
        ListTestCaseHistoriesRequest request = new ListTestCaseHistoriesRequest();
        request.withTestcaseId("{testcase_id}");
        request.withProjectId("{project_id}");
        ListTestCaseHistoriesRequestBody body = new ListTestCaseHistoriesRequestBody();
        body.withVersionId("932opbuaarweqf");
        body.withLimit(10);
        body.withOffset(0);
        request.withBody(body);
        try {
            ListTestCaseHistoriesResponse response = client.listTestCaseHistories(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
# 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 = ListTestCaseHistoriesRequest()
        request.testcase_id = "{testcase_id}"
        request.project_id = "{project_id}"
        request.body = ListTestCaseHistoriesRequestBody(
            version_id="932opbuaarweqf",
            limit=10,
            offset=0
        )
        response = client.list_test_case_histories(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
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.ListTestCaseHistoriesRequest{}
	request.TestcaseId = "{testcase_id}"
	request.ProjectId = "{project_id}"
	request.Body = &model.ListTestCaseHistoriesRequestBody{
		VersionId: "932opbuaarweqf",
		Limit: int32(10),
		Offset: int32(0),
	}
	response, err := client.ListTestCaseHistories(request)
	if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}

更多

更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。

状态码

状态码

描述

200

查询成功。示例1:获取用例历史记录基础示例。示例2:获取用例历史记录,目录(cataName)、状态(statusName)、等级(rank)、处理人(owner)、迭代(versionName)、模块(moduleName)、版本号(releaseDev)、缺陷(defectId)、需求(issueId)、测试步骤(steps)、描述(description)、预置条件(preparation)均有变更的返回示例。

400

Bad Request

401

Unauthorized

404

Not Found

500

Internal Server Error

错误码

请参见错误码

相关文档