microsoft / microsoft/azure-devops-python-api
need help to get the run_id based on the test_case_id
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 684
- 派生
- 218
- 平均合并
- 8 天 10 小时
- 30 天内合并 PR
- 1
描述
Hi All,
i have use case where i need to select Mark outcome and update the test result automatically for that purpose i need run_id of a test_case how to get that any idea? For time being i am using hard coded run_id
here is the code for the same
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}")
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 issue 中展示的 Azure DevOps TestClient 方法开始,尤其是 get_test_result_by_id 和 update_test_results,并检查可用的测试运行查找操作。完成标准是记录如何从 test_case_id 获取相关的 run_id,并明确 update_test_results 需要哪个标识符。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- azure, python
- 领域
- api, testing-qa
- Issue 类型
- 文档
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 25/100