Код: Выделить всё
{ "$id": "1", "innerException": null, "message": "TestPointId, testCaseId, testCaseRevision, testCaseTitle must be specified for planned test results.", "typeName": "Microsoft.TeamFoundation.TestManagement.WebApi.InvalidPropertyException, Microsoft.TeamFoundation.TestManagement.WebApi", "typeKey": "InvalidPropertyException", "errorCode": 0, "eventId": 3000 } `async def Associate_test_results(session, test_run_id, test_points):
если нет test_points:
возврат
Код: Выделить всё
headers = get_headers()
url = f"https://dev.azure.com/{org_name}/{project_name}/_apis/test/runs/{test_run_id}/results?api-version=7.0"
test_case_results = []
results = parse_results_xml() # Calls function that returns the test results
for test in results:
test_case_id = test.get('test_case_id')
outcome = test.get('outcome', "Aborted")
error_message = test.get('error_message')
# Accessing elapsed time in seconds, and converting to milliseconds
elapsed_seconds = test.get('elapsed_seconds', 0)
elapsed_ms = elapsed_seconds * 1000
test_point = next((point for point in test_points if point.get("testCase", {}).get("id") == test_case_id), None)
if test_point:
point_id = test_point.get("id")
revision = test_point.get("testCase", {}).get("revision")
title = test_point.get("testCase", {}).get("name", f"Test {test_case_id}")
result = {
"testPoint": {"id": point_id},
"testCase": {"id": test_case_id},
"testCaseRevision": revision,
"testCaseTitle": title,
"automatedTestName": f"TestClass.{test_case_id}",
"automatedTestType": "RobotAutomation",
"priority": 1,
"outcome": outcome,
"state": "Completed",
"durationInMs": elapsed_ms,
"actionResults": [
{
"actionPath": "000001",
"outcome": outcome,
"comment": f"Test result: {test_case_id}",
}
]
}
if outcome == "Failed" and error_message:
result["errorMessage"] = error_message
test_case_results.append(result)
if test_case_results:
try:
async with session.post(url, headers=headers, json=test_case_results) as response:
if response.status == 200:
log.info("Test results successfully associated.")
results = await response.json() # Returns the created results
await upload_attachments_to_results(session, test_run_id, results)
return results
else:
log.error(f"Error associating results: {response.status}, {await response.text()}")
except aiohttp.ClientError as e:
log.error(f"Error associating results: {e}")
Ошибка:
При использовании этого кода с API версии 7.0 возвращается ошибка 400 Bad Request со следующим сообщением:
"Для запланированных результатов теста необходимо указать TestPointId, testCaseId, testCaseRevision, testCaseTitle."
Вопросы:
Почему эта ошибка возникают только с версией API 7.0, а не с 5.0?
Как решить эту проблему и успешно связать результаты теста с использованием версии 7.0?
Я попробовал проверить параметры (testPointId, testCaseId и т. д. ), но вроде всё правильно пройдено. Любая помощь или идеи будут оценены по достоинству!
Подробнее здесь: https://stackoverflow.com/questions/792 ... in-version
Мобильная версия