microsoft / microsoft/azure-devops-python-api

need help to get the run_id based on the test_case_id

Offen
#485 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Vorherrschende Sprache
Python
Sterne
684
Forks
218
Ø Merge
8 T. 10 Std.
Gemergte PRs (30 T.)
1

Beschreibung

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}")

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit den im Issue gezeigten Azure DevOps TestClient-Methoden, insbesondere get_test_result_by_id und update_test_results, und prüfe die verfügbaren Suchoperationen für Testläufe. Als erledigt gilt die Dokumentation, wie die relevante run_id aus einer test_case_id ermittelt wird, sowie die Klärung, welchen Bezeichner update_test_results erwartet.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
azure, python
Bereich
api, testing-qa
Issue-Typ
Dokumentation
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.