update_test_results() is failing even after giving correct runid as well as test case id

Aperta
#484 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
azure, python
Ambito
api

Direzione di ricerca

Inizia esaminando i punti di ingresso di Azure DevOps TestClient get_test_result_by_id() e update_test_results(), insieme al modello TestCaseResult utilizzato nell'esempio. Riproduci la richiesta con gli identificatori run e result forniti e confronta i campi identificatore previsti dall'API con i valori passati. Il lavoro è concluso quando l'uso degli identificatori e l'errore risultante sono documentati chiaramente oppure il comportamento errato è confermato con un test mirato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Hi All,

  1. I am calling update_test_results() but geting below error Test result 1286862 does not exist in test run 8239298. Here i am passing correct run_id as well as test_case_id here is the code.

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}")
What is the problem in this

Lingua principale
Python
Stelle
684
Fork
218
Merge medio
8g 10h
PR unite (30g)
1

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di microsoft/azure-devops-python-api

Tutte le issue di microsoft/azure-devops-python-api

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.