microsoft / microsoft/azure-devops-python-api

need help to get the run_id based on the test_case_id

Abierto
#485 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Lenguaje dominante
Python
Estrellas
684
Forks
218
Merge medio
8 d 10 h
PR fusionados (30 d)
1

Descripción

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

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza con los métodos de Azure DevOps TestClient mostrados en el issue, especialmente get_test_result_by_id y update_test_results, y comprueba las operaciones disponibles para buscar ejecuciones de pruebas. Se considera terminado documentar cómo obtener el run_id relevante a partir de un test_case_id y aclarar qué identificador espera update_test_results.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
azure, python
Área
api, testing-qa
Tipo de issue
Documentación
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Estancado
Claridad
Necesita aclaración
Aptitud para principiantes
25/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.