更新时间:2025-12-27 GMT+08:00
分享

查询用例结果 - ShowCaseResult

功能介绍

查询用例结果

调用方法

请参见如何调用API

URI

POST /v4/{project_id}/versions/{version_uri}/testcases/{case_uri}/results/batch-query

表1 路径参数

参数

是否必选

参数类型

描述

project_id

String

参数解释:

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

约束限制:

不涉及

取值范围:

项目uuid应符合如下规则:长度等于32位,包含大小写字母、数字

默认取值:

不涉及

version_uri

String

版本URI

case_uri

String

用例uri

请求参数

表2 请求Header参数

参数

是否必选

参数类型

描述

X-Auth-Token

String

参数解释:

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

约束限制:

必传。

取值范围:

字符串长度不少于1,不超过10万。

默认取值:

不涉及。

表3 请求Body参数

参数

是否必选

参数类型

描述

uri

String

结果URI

task_uri

String

测试任务URI

task_id

String

执行id

release_dev

String

版本号

execute_id

String

测试套当次执行id,同一个测试套每次执行的id唯一

case_uris

Array of strings

测试套中用例的uri

page_no

Integer

当前页数

page_size

Integer

每页条数

sort_field

String

排序字段

sort_type

String

参数解释:

排序类型

约束限制:

不涉及

取值范围:

  • ASC,升序。

  • DESC,降序。

默认取值:

不涉及

响应参数

状态码:200

表4 响应Body参数

参数

参数类型

描述

total

Integer

参数解释

总数

取值范围

不涉及

page_no

String

参数解释

分页编码

取值范围

不涉及

page_size

String

参数解释

分页大小

取值范围

不涉及

value

Array of TestResultVo objects

请求返回的数据

表5 TestResultVo

参数

参数类型

描述

uri

String

结果URI

name

String

用例结果名称

author

String

创建人ID

rank

Integer

级别

result

Integer

测试结果Code

round

Integer

执行批次

preparation

String

前置条件

description

String

描述

region

String

逻辑Region

steps

Array of ResultStepVo objects

测试步骤信息

number

String

用例结果编号

author_name

String

创建人名称

begin_time

String

执行开始时间

begin_time_timestamp

Long

执行开始时间时间戳

end_time

String

执行结束时间

end_time_timestamp

Long

执行结束时间时间戳

creation_date

String

创建时间

creation_date_timestamp

Long

创建时间时间戳

last_modified

String

最后修改时间

last_modified_timestamp

Long

最后修改时间

last_change_time

String

最后变更时间

last_change_time_timestamp

Long

最后变更时间

dfx_test_result

String

DFX测试结果

failure_cause

String

失败原因

parent_uri

String

父节点URI(分支用例URI或迭代用例URI)

test_case_uri

String

分支用例URI

test_case_name

String

用例名称

task_uri

String

测试任务URI

result_name

String

测试结果

test_result_ae

String

是否自动化执行

executor_id

String

执行人ID

executor_name

String

执行人名称

task_id

String

执行机任务ID

execute_id

String

执行ID

time_cost

Integer

执行耗时

step_txt

String

测试步骤

step_expect

String

测试步骤期望结果

step_actual

String

测试步骤实际结果

step_result

String

测试步骤结果

release_dev

String

版本号

creation_version_uri

String

创建版本URI

version_uri

String

版本URI

project_uuid

String

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

report_url

String

第三方过来的执行结果,返回跳转到第三方的url

test_case_number

String

测试用例编号

service_type

String

参数解释:

服务类型

约束限制:

不涉及

取值范围:

  • -1,全量用例。

  • 0,手工测试。

  • 1,接口自动化。

  • 7,功能自动化。

  • 8,WebUI自动化。

  • 100,自定义自动化(工厂)。

  • 11,性能自动化。

默认取值:

不涉及

表6 ResultStepVo

参数

参数类型

描述

result

String

结果

test_step

String

测试步骤

expect_result

String

预期结果

actual_result

String

实际结果

result_name

String

测试结果名称

状态码:400

表7 响应Body参数

参数

参数类型

描述

error_code

String

参数解释:

接口调用失败错误码

取值范围:

不涉及

error_msg

String

参数解释:

接口调用失败错误信息

取值范围:

不涉及

状态码:401

表8 响应Body参数

参数

参数类型

描述

error_code

String

参数解释:

接口调用失败错误码

取值范围:

不涉及

error_msg

String

参数解释:

接口调用失败错误信息

取值范围:

不涉及

状态码:404

表9 响应Body参数

参数

参数类型

描述

error_code

String

参数解释:

接口调用失败错误码

取值范围:

不涉及

error_msg

String

参数解释:

接口调用失败错误信息

取值范围:

不涉及

状态码:500

表10 响应Body参数

参数

参数类型

描述

error_code

String

参数解释:

接口调用失败错误码

取值范围:

不涉及

error_msg

String

参数解释:

接口调用失败错误信息

取值范围:

不涉及

请求示例

根据查询条件获取测试报告列表

post https://{endpoint}/v4/30649eb093c2479d92c74c75d36ef280/versions/v91i0000vq98suq1/testcases/v91j0000vq997opk/results/batch-query

{
  "page_no" : 1,
  "page_size" : 15
}

响应示例

状态码:200

OK

{
  "total":2,
   "page_no": 1,
  "page_size": 15
  "value": [
    {
      "uri": "v9220000vqtdi7go",
      "name": "基线 Result2024-08-31",
      "author": "xxx",
      "result": 0,
      "region": "cn-north-7",
      "steps": [
        {
          "result": "0",
          "test_step": "",
          "expect_result": "",
          "actual_result": "",
          "result_name": "成功"
        }
      ],
      "begin_time": "2024-08-31 16:34:24",
      "begin_time_timestamp": 1725093264000,
      "end_time": "2024-08-31 16:34:34",
      "end_time_timestamp": 1725093274000,
      "last_modified": "2024-09-10 10:58:55",
      "last_modified_timestamp": 1725937135000,
      "last_change_time": "2024-08-31 16:34:44",
      "last_change_time_timestamp": 1725093284000,
      "failure_cause": "12345678",
      "parent_uri": "v91j0000vq997opk",
      "test_case_uri": "v91j0000vq997opk",
      "test_case_name": "用例3",
      "result_name": "成功",
      "task_id": "1806594740082704384",
      "time_cost": 10000,
      "step_txt": "[\"\"]",
      "step_expect": "[\"\"]",
      "step_actual": "[\"\"]",
      "step_result": "[\"0\"]",
      "creation_version_uri": "v91i0000vq98suq1",
      "version_uri": "v91i0000vq98suq1"
    },
    {
      "uri": "v91o0000vqr7jopj",
      "name": "基线 Result2024-08-30",
      "author": "xxx",
      "result": 1,
      "region": "cn-north-7",
      "steps": [
        {
          "result": "1",
          "test_step": "",
          "expect_result": "",
          "actual_result": "",
          "result_name": "失败"
        }
      ],
      "begin_time": "2024-08-30 20:11:54",
      "begin_time_timestamp": 1725019914000,
      "end_time": "2024-08-30 20:12:04",
      "end_time_timestamp": 1725019924000,
      "last_modified": "2024-08-30 20:12:14",
      "last_modified_timestamp": 1725019934000,
      "last_change_time": "2024-08-30 20:12:14",
      "last_change_time_timestamp": 1725019934000,
      "failure_cause": "unknown failure",
      "parent_uri": "v91j0000vq997opk",
      "test_case_uri": "v91j0000vq997opk",
      "test_case_name": "用例3",
      "result_name": "失败",
      "task_id": "1804076583577190400",
      "time_cost": 10000,
      "step_txt": "[\"\"]",
      "step_expect": "[\"\"]",
      "step_actual": "[\"\"]",
      "step_result": "[\"1\"]",
      "creation_version_uri": "v91i0000vq98suq1",
      "version_uri": "v91i0000vq98suq1"
    }
  ]
}

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 ShowCaseResultSolution {

    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();
        ShowCaseResultRequest request = new ShowCaseResultRequest();
        request.withVersionUri("{version_uri}");
        request.withCaseUri("{case_uri}");
        request.withProjectId("{project_id}");
        QueryCaseResultInfo body = new QueryCaseResultInfo();
        body.withPageSize(15);
        body.withPageNo(1);
        request.withBody(body);
        try {
            ShowCaseResultResponse response = client.showCaseResult(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 = ShowCaseResultRequest()
        request.version_uri = "{version_uri}"
        request.case_uri = "{case_uri}"
        request.project_id = "{project_id}"
        request.body = QueryCaseResultInfo(
            page_size=15,
            page_no=1
        )
        response = client.show_case_result(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
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.ShowCaseResultRequest{}
	request.VersionUri = "{version_uri}"
	request.CaseUri = "{case_uri}"
	request.ProjectId = "{project_id}"
	pageSizeQueryCaseResultInfo:= int32(15)
	pageNoQueryCaseResultInfo:= int32(1)
	request.Body = &model.QueryCaseResultInfo{
		PageSize: &pageSizeQueryCaseResultInfo,
		PageNo: &pageNoQueryCaseResultInfo,
	}
	response, err := client.ShowCaseResult(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

错误码

请参见错误码

相关文档