I got few API's like to the number of testcases (count) in a particular Suite ID

GET https://dev.azure.com/{organization}/{project}/_apis/testplan/Plans/{planId}/Suites/{suiteId}/TestCase?api-version=5.0-preview.2

From this we can able to get the list of testcases the in the Suite ID from the Azure Test plan.

In the same way, we are having an GET API

GET https://dev.azure.com/{organization}/{project}/_apis/testplan/Plans/{planId}/Suites/{suiteId}/TestPoint?api-version=5.0-preview.2

From this we are able to the get exact point information. But with this API we are getting the only the last run details of that particular point or testcase. We are not getting the details of Test case history.

I have found an API from Microsoft

https://learn.microsoft.com/en-us/rest/api/azure/devops/test/test-history/query?view=azure-devops-rest-6.0

tried in in postman by giving body

POST https://dev.azure.com/{organization}/{project}/_apis/test/Results/testhistory?api-version=6.0-preview.2

Tried to test history

Body:

{
    "automatedTestName":"E2E_K1_B5_009",
    "testCaseId":82167
}

Excepted result: to get the entire history of test case

Actual result :

{
    "$id": "1",
    "innerException": null,
    "message": "Value 0 for argument GroupBy is not supported.",
    "typeName": "Microsoft.TeamFoundation.TestManagement.WebApi.InvalidPropertyException, Microsoft.TeamFoundation.TestManagement.WebApi",
    "typeKey": "InvalidPropertyException",
    "errorCode": 0,
    "eventId": 3000
}

I need an API to get entire testcase history, like how many times the test case is executed in a particular suite

Is there any of the API, like which provides the details of test case execution history to know the count of test case execution in a particular suite??

1

There are 1 best solutions below

1
On

Please note that, using the Test History - Query REST API we can only get history of a test method (Automated tests). It's not applied for manual tests.

"message": "Value 0 for argument GroupBy is not supported.",

According to the error message, you need to specify a valid GroupBy value in the request body. See Request Body for details.

enter image description here

Test the scenario, it works with the value "groupBy": "Branch", specified in the request body.

{
  "groupBy": "Branch",
  "automatedTestName": "StudentGrades.UnitTests.GradeCalculatorTests.GetGradeByPercentage_EqualTest(92)",
  "testCaseId":xxx
}

enter image description here }

For manual tests, there isn't an API endpoint to achieve that directly. However, we can get the test case run history from UI.

  1. Go to TestPlans > Test suite > Switch to Execute tab and select the TestCase for which you want to see the execution history.

enter image description here

  1. Select View execution history from the context, we can see the test case run history. enter image description here

  2. We can also click the link "Open execution history for current test point" to see the results.

enter image description here