microsoft / microsoft/azure-devops-python-api

update_test_results() is failing even after giving correct runid as well as test case id

未关闭
#484 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
Python
星标
684
派生
218
平均合并
8 天 10 小时
30 天内合并 PR
1

描述

Hi All,

  1. I am calling update_test_results() but geting below error Test result 1286862 does not exist in test run 8239298. Here i am passing correct run_id as well as test_case_id here is the code.

from azure.devops.connection import Connection
from msrest.authentication import BasicAuthentication
from azure.devops.exceptions import AzureDevOpsServiceError
from azure.devops.v7_0.test.models import TestCaseResult

organization_url = 'https://dev.azure.com/msazuredev'
personal_access_token = ''
project_name = 'AzureForOperatorsIndustry'
run_id = 8239298 # Replace with the actual run ID
test_case_id = 1286862 # Replace with the actual test case ID
outcome = 'Failed' # Replace with the desired outcome (e.g., 'Passed', 'Failed', 'Blocked')

Create a connection to Azure DevOps using PAT

credentials = BasicAuthentication('', personal_access_token)
connection = Connection(base_url=organization_url, creds=credentials)

Get the test client

test_client = connection.clients.get_test_client()

try:
# Check if the test result exists in the specified test run
existing_result = test_client.get_test_result_by_id(project=project_name, run_id=run_id, test_case_result_id=test_case_id)

# Create a list of TestCaseResult to specify the update details
results = [
    TestCaseResult(id=test_case_id, state=outcome)
]

# Update the test results using the TestClient
updated_results = test_client.update_test_results(results, project=project_name, run_id=run_id)

# Print the updated results
for result in updated_results:
    print(f"Updated Test Result - Test Case ID: {result.id}, Outcome: {result.state}")

except AzureDevOpsServiceError as e:
if "cannot be found" in str(e):
print(f"Test result {test_case_id} does not exist in test run {run_id}. Skipping update.")
else:
print(f"Error updating test results: {e}")
print(f"Details: {e.response.text}")
What is the problem in this

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先检查 Azure DevOps TestClient 的入口点 get_test_result_by_id() 和 update_test_results(),以及示例中使用的 TestCaseResult 模型。使用提供的 run 和 result 标识符重新发起请求,并将 API 预期的标识符字段与传入的值进行比较。当标识符的使用方式及由此产生的错误得到清晰记录,或通过一个针对性的测试确认失败行为时,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
azure, python
领域
api
Issue 类型
缺陷
难度
2/5
预计耗时
1-3 小时
活跃度
停滞
描述清晰度
需要澄清
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。