如何使用 Python REST API 在 Azure DevOps 中更新测试结果?

How to Update Test Results in Azure DevOps with Python REST API?

如何使用 Python REST API 在 Azure DevOps 中更新测试结果? 我已经使用 vsts python 库连接了 azure rest api,我可以检索测试 运行 结果或测试 运行s,但我无法更新测试用例结果.如果有人知道这部分,请提供帮助。

已连接模块用于测试检索 运行 vsts.core.v4_1.core_client.TestClient

连接的模块应该是vsts.test.v4_1.test_client.TestClient而不是vsts.core.v4_1.core_client.TestClient

如果我们想更新测试结果,我们可以使用test_client中的test_client.update_test_results()方法。 更多信息请参考Azure Devops Python Rest API source code.

personal_access_token = 'xxx'
organization_url = 'https://dev.azure.com/{organization}'
# Create a connection to the org
credentials = BasicAuthentication('', personal_access_token)
connection = VssConnection(base_url=organization_url, creds=credentials)
test_client = connection.get_client('vsts.test.v4_1.test_client.TestClient')
update_testResults = test_client.update_test_results(testresults,projectName,run.id)