文档首页/ 测试计划 CodeArts TestPlan/ API参考/ API/ 测试套管理/ 更新测试套任务 - UpdateTask
更新时间:2026-10-22 GMT+08:00
分享

更新测试套任务 - UpdateTask

功能介绍

此接口用于更新测试套任务,同页面 测试 -> 测试执行 -> 右侧上方筛选分支,点击新建套件

调用方法

请参见如何调用API。

URI

PUT /v4/{project_id}/tasks/{task_uri}

表1 路径参数

参数

是否必选

参数类型

描述

project_id

是

String

参数解释:

项目UUID,项目唯一标识。获取方式请参见获取项目ID

约束限制:

不涉及

取值范围:

长度等于32位,包含大小写字母、数字

默认取值:

不涉及

task_uri

是

String

任务uri

请求参数

表2 请求Header参数

参数

是否必选

参数类型

描述

X-Auth-Token

是

String

参数解释:

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

约束限制:

不涉及

取值范围:

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

默认取值:

不涉及

表3 请求Body参数

参数

是否必选

参数类型

描述

uri

否

String

参数解释

指定创建任务的uri

约束限制

不涉及

取值范围

不涉及

默认取值

不涉及

name

是

String

参数解释

名称

约束限制

不涉及

取值范围

不涉及

默认取值

不涉及

stage

否

String

参数解释

测试阶段

约束限制

不涉及

取值范围

不涉及

默认取值

不涉及

number

否

String

参数解释

编号

约束限制

不涉及

取值范围

不涉及

默认取值

不涉及

tags

否

String

参数解释

标记id

约束限制

不涉及

取值范围

不涉及

默认取值

不涉及

description

否

String

参数解释

描述

约束限制

不涉及

取值范围

不涉及

默认取值

不涉及

region

否

String

参数解释

区域

约束限制

不涉及

取值范围

不涉及

默认取值

不涉及

version_uri

否

String

参数解释

分支/迭代uri

约束限制

不涉及

取值范围

11-34位字母/数字

默认取值

不涉及

owner_id

否

String

参数解释

处理人/责任人id

约束限制

不涉及

取值范围

不涉及

默认取值

不涉及

parent_uri

否

String

参数解释

父任务uri

约束限制

不涉及

取值范围

不涉及

默认取值

不涉及

test_case_condition

否

String

参数解释

动态任务用例过滤条件

约束限制

不涉及

取值范围

不涉及

默认取值

不涉及

service_type

否

Integer

参数解释

服务类型

约束限制

不涉及

取值范围

0:功能测试 1:接口测试 11:性能测试

默认取值

不涉及

module_id

否

String

参数解释

模块id

约束限制

不涉及

取值范围

不涉及

默认取值

不涉及

module_name

否

String

参数解释

模块名称

约束限制

不涉及

取值范围

不涉及

默认取值

不涉及

release_dev

否

String

参数解释

发布版本号

约束限制

不涉及

取值范围

不涉及

默认取值

不涉及

status_code

否

Integer

参数解释

状态code

约束限制

不涉及

取值范围

不涉及

默认取值

不涉及

ext_param

否

String

参数解释

扩展参数

约束限制

不涉及

取值范围

不涉及

默认取值

不涉及

execute_way

否

Integer

参数解释

执行方式

约束限制

不涉及

取值范围

1:串行,2:并行

默认取值

不涉及

execute_type

否

Integer

参数解释

执行类型

约束限制

不涉及

取值范围

(0:冒烟,1:定时)

默认取值

不涉及

plan_start_timestamp

否

Long

参数解释

计划开始时间戳,

约束限制

不涉及

取值范围

当传入-1时,时间置为空

默认取值

不涉及

plan_end_timestamp

否

Long

参数解释

计划结束时间戳

约束限制

不涉及

取值范围

当传入-1时,时间置为空

默认取值

不涉及

assign_case_uris

否

Array of strings

参数解释

任务关联用例uri数组,CloudDragon环境

约束限制

不涉及

取值范围

不涉及

默认取值

不涉及

case_operation_info

否

CaseOperationInfo object

参数解释

用例操作信息

约束限制

不涉及

取值范围

不涉及

默认取值

不涉及

only_update_status

否

Boolean

参数解释

是否只需要修改测试套状态

约束限制

不涉及

取值范围

true:是 false:否

默认取值

不涉及

is_async

否

Boolean

参数解释

是否异步

约束限制

不涉及

取值范围

true:是 false:否

默认取值

不涉及

changes

否

Array of ResourceChangeInfo objects

参数解释

自定义字段的更新记录

约束限制

不涉及

取值范围

不涉及

默认取值

不涉及

表4 CaseOperationInfo

参数

是否必选

参数类型

描述

empty

否

Boolean

参数解释

是否为空

约束限制

不涉及

取值范围

true:是 false:否

默认取值

不涉及

test_cases_info

否

Array of AssignCaseInfo objects

参数解释

用例关联信息

约束限制

不涉及

取值范围

不涉及

默认取值

不涉及

set_up_cases_info

否

Array of AssignCaseInfo objects

参数解释

前置用例关联信息

约束限制

不涉及

取值范围

不涉及

默认取值

不涉及

tear_down_cases_info

否

Array of AssignCaseInfo objects

参数解释

后置用例关联信息

约束限制

不涉及

取值范围

不涉及

默认取值

不涉及

表5 AssignCaseInfo

参数

是否必选

参数类型

描述

case_uri

否

String

参数解释

用例uri

约束限制

不涉及

取值范围

11-34位字母/数字

默认取值

不涉及

is_available

否

Integer

参数解释

是否可用

约束限制

不涉及

取值范围

true:是 false:否

默认取值

不涉及

表6 ResourceChangeInfo

参数

是否必选

参数类型

描述

field_name

否

String

参数解释

字段名称

约束限制

不涉及

取值范围

不涉及

默认取值

不涉及

old_value

否

String

参数解释

旧的value

约束限制

不涉及

取值范围

不涉及

默认取值

不涉及

new_value

否

String

参数解释

新的value

约束限制

不涉及

取值范围

不涉及

默认取值

不涉及

old_key

否

String

参数解释

旧的key

约束限制

不涉及

取值范围

不涉及

默认取值

不涉及

new_key

否

String

参数解释

新的key

约束限制

不涉及

取值范围

不涉及

默认取值

不涉及

响应参数

状态码:200

表7 响应Body参数

参数

参数类型

描述

value

String

参数解释

请求返回的数据

取值范围

不涉及

状态码: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

参数解释:

接口调用失败错误信息

取值范围:

不涉及

请求示例

更新测试套任务

put https://{endpoint}/v4/300c6295a54c4c698608c878f47ddd59/tasks/v91j0000vldlep5u

{
  "description" : "",
  "name" : "样例功能套件",
  "owner_id" : "e8d27b5521a64fb28a8fd9c99cd66eb3",
  "tags" : [ "tag1" ],
  "number" : "002",
  "service_type" : 0,
  "status_code" : "0",
  "module_name" : "",
  "release_dev" : "",
  "execute_way" : 1,
  "version_uri" : "v91j0000vldleodb",
  "plan_start_timestamp" : -1,
  "plan_end_timestamp" : -1
}

响应示例

状态码:200

{
  "value" : "success"
}

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
57
58
59
60
61
62
63
64
65
66
67
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 UpdateTaskSolution {

    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");
        String projectId = "{project_id}";

        ICredential auth = new BasicCredentials()
                .withProjectId(projectId)
                .withAk(ak)
                .withSk(sk);

        CloudtestClient client = CloudtestClient.newBuilder()
                .withCredential(auth)
                .withRegion(CloudtestRegion.valueOf("<YOUR REGION>"))
                .build();
        UpdateTaskRequest request = new UpdateTaskRequest();
        request.withTaskUri("{task_uri}");
        TaskInfo body = new TaskInfo();
        List<String> listbodyTags = new ArrayList<>();
        listbodyTags.add("tag1");
        body.withPlanEndTimestamp(-1L);
        body.withPlanStartTimestamp(-1L);
        body.withDescription("");
        body.withExecuteWay(1);
        body.withStatusCode(0);
        body.withReleaseDev("");
        body.withModuleName("");
        body.withTags(listbodyTags);
        body.withNumber("002");
        body.withServiceType(0);
        body.withOwnerId("e8d27b5521a64fb28a8fd9c99cd66eb3");
        body.withName("样例功能套件");
        body.withVersionUri("v91j0000vldleodb");
        request.withBody(body);
        try {
            UpdateTaskResponse response = client.updateTask(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
40
41
42
43
44
45
46
47
48
49
50
# 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"]
    projectId = "{project_id}"

    credentials = BasicCredentials(ak, sk, projectId)

    client = CloudtestClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(CloudtestRegion.value_of("<YOUR REGION>")) \
        .build()

    try:
        request = UpdateTaskRequest()
        request.task_uri = "{task_uri}"
        listTagsbody = [
            "tag1"
        ]
        request.body = TaskInfo(
            plan_end_timestamp=-1,
            plan_start_timestamp=-1,
            description="",
            execute_way=1,
            status_code=0,
            release_dev="",
            module_name="",
            tags=listTagsbody,
            number="002",
            service_type=0,
            owner_id="e8d27b5521a64fb28a8fd9c99cd66eb3",
            name="样例功能套件",
            version_uri="v91j0000vldleodb"
        )
        response = client.update_task(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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
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")
    projectId := "{project_id}"

    auth, err := basic.NewCredentialsBuilder().
        WithAk(ak).
        WithSk(sk).
        WithProjectId(projectId).
        SafeBuild()

    if err != nil {
        fmt.Println(err)
        return
    }

    hcClient, err := cloudtest.CloudtestClientBuilder().
         WithRegion(region.ValueOf("<YOUR REGION>")).
         WithCredential(auth).
         SafeBuild()


    if err != nil {
        fmt.Println(err)
        return
    }

    client := cloudtest.NewCloudtestClient(hcClient)

    request := &model.UpdateTaskRequest{}
	request.TaskUri = "{task_uri}"
	var listTagsbody = []string{
        "tag1",
    }
	planEndTimestampTaskInfo:= int64(-1)
	planStartTimestampTaskInfo:= int64(-1)
	descriptionTaskInfo:= ""
	executeWayTaskInfo:= int32(1)
	statusCodeTaskInfo:= int32(0)
	releaseDevTaskInfo:= ""
	moduleNameTaskInfo:= ""
	numberTaskInfo:= "002"
	serviceTypeTaskInfo:= int32(0)
	ownerIdTaskInfo:= "e8d27b5521a64fb28a8fd9c99cd66eb3"
	nameTaskInfo:= "样例功能套件"
	versionUriTaskInfo:= "v91j0000vldleodb"
	request.Body = &model.TaskInfo{
		PlanEndTimestamp: &planEndTimestampTaskInfo,
		PlanStartTimestamp: &planStartTimestampTaskInfo,
		Description: &descriptionTaskInfo,
		ExecuteWay: &executeWayTaskInfo,
		StatusCode: &statusCodeTaskInfo,
		ReleaseDev: &releaseDevTaskInfo,
		ModuleName: &moduleNameTaskInfo,
		Tags: &listTagsbody,
		Number: &numberTaskInfo,
		ServiceType: &serviceTypeTaskInfo,
		OwnerId: &ownerIdTaskInfo,
		Name: &nameTaskInfo,
		VersionUri: &versionUriTaskInfo,
	}
	response, err := client.UpdateTask(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

错误码

请参见错误码。

相关文档