Search code examples
tfsgetazure-devopspostman

How to get "Resolution" variable from testcase on an TFS/VSTS server


I have a lot of testcases which are stored in my microsoft TFS server and i am trying to make changes to failed testcases via REST API. I am therefor trying to create an application which can get and patch (update) values from an Microsoft TFS server but i can't get or patch the "resolution" variable because it doesn't get parsed when i execute my get command. The resolution variable is the variable which declares what type of testfailure we are dealing with (Unknown/Testerror/ProductError).

I think i have to specify a filter which makes me able to extract it, but i am not so sure. I was hoping that someone could help.

This is my GET command which i execute in postman, but i dont add anything in the detailsToInclude field.

https://{instance}/DefaultCollection/{project}/_apis/test/runs/{run}/results/{result}?api-version={version}[&detailsToInclude={string}]

I get almost every variable returned except the resolution variable which i wanna edit.


Solution

  • The detailsToInclude parameter describe clearly:

    enum { None, Iterations, WorkItems}

    • None - Return results with core fields values only. Core fields includes State, Outcome, Priority, AutomatedTestName,
      AutomatedTestStorage, Comments, ErrorMessage etc.
    • Iterations - Return results with core field values and test iteration details.
    • WorkItems - Return results with core field values and associated workitems information.

    Source Link

    The rest API will only return core filed not every field. Instead, you could try to use SDK, client API to get test result. How to please refer-- TFS API: How to get latest test result for a test case

    However, you could be able to use Rest API to Update test results for a test run with resolutionState parameter in Content-Type: application/json such as below:

    PATCH https://{instance}/DefaultCollection/{project}/_apis/test/runs/{run}/results?api-version={version}
    
    [
      {  
        "id": { int },
        "state": {
        enum { Pending, Queued, InProgress, Paused, Completed }
        },
        "computerName": { string },    
        "resolutionState": { string },
        "priority": { int },
        "failureType": { string }, 
        "owner": {
           "DisplayName": {string}
        },
        "runBy": {
           "DisplayName": {string}
        },
        "outcome": {
              enum { None, Passed, Failed, Inconclusive, Timeout, Aborted, Blocked, NotExecuted, Warning, Error, NotApplicable, Paused, InProgress}
        },
        "errorMessage": { string },
        "comment": { string },
        "startedDate": { DateTime },
        "completedDate": { DateTime },
        "durationInMs": { long },
        "associatedBugs": [ 
            {
             { "id" : {int} }
            } 
        ]
      }
    ]