Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

Get test result for a specific test case #19

Open
pbissert opened this issue Feb 6, 2019 · 6 comments
Open

Get test result for a specific test case #19

pbissert opened this issue Feb 6, 2019 · 6 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@pbissert
Copy link

pbissert commented Feb 6, 2019

In .../samples/test.py, you have a function, def get_test_results(context):

This appears to get all of the test results for a given context. Is it possible to get the test result of a single test case?

@vtbassmatt vtbassmatt added enhancement New feature or request help wanted Extra attention is needed labels Feb 6, 2019
@vtbassmatt
Copy link
Member

There's an endpoint for it, so there will be a Python API for it as well.

@pbissert
Copy link
Author

pbissert commented Feb 6, 2019

You're right. That didn't exist in the API v4.1, so now we wait.

@tedchamb
Copy link
Member

tedchamb commented Feb 6, 2019

@pbissert Is this what you are looking for get_test_result_by_id:

https://github.com/Microsoft/azure-devops-python-api/blob/d16026911f93361becb52d2f1c124d5c3e8a82e7/vsts/vsts/test/v4_1/test_client.py#L1167

The API is there in 4.1, it is just not documented on the site.

@pbissert
Copy link
Author

pbissert commented Feb 6, 2019

@tedchamb Thanks for pointing that out. Let me see if I can get it to work.

Really I'm just trying to get the latest outcome for a given test case. It seems like the path to get there is to loop through all run ids (get_test_runs) loop through the test results for an iterations run id, then check the test case.

desired_test_case = 1234
for run in test_client.get_test_runs('Portfolio'):
    for res in test_client.get_test_results('Portfolio', run.id):
        if res.test_case == desired_test_case:
            return res.outcome
return None

Is there a more efficient way?

@BOB-PHL
Copy link

BOB-PHL commented Dec 30, 2020

@tedchamb @vtbassmatt

Hello, I had a couple of follow-up questions.
With VSTS v4.1 test_client.py referenced above, I'd like to get the test results (passed, failed, blocked, etc.) for the tests in a test suite.

  1. With the 'get_test_results' method, the test results are returned given you have the run_id. Is there a way to get the run_id's for a given 'test case'/'test case ID'?

  2. And relatedly, the 'get_test_cases' method returns object addresses for 'point_assignments' and for 'test_case'. Is there a way to obtain the object values/contents for 'point_assignments' and for 'test_case'?

Thanks very much, in advance, for any help/guidance.

@vtbassmatt
Copy link
Member

Hi @BOB-PHL. If there's a REST API in the Test area which does what you want, then it works from Python. Unfortunately I don't know enough about the Test APIs to comment.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants