3

I am making a program in ASP .NET Core and I am trying to get the Test Runs for specific build in specific Build Definition. So far I have created some some methods which can get the build definition and all night builds for that specific build. Now I would like to get all test results from the mentioned night build

enter image description here

The Idea is to get the list of all tests and do some statistics with them. I am using the following libraries

using Microsoft.TeamFoundation.Build.WebApi;
using Microsoft.TeamFoundation.Core.WebApi;
using Microsoft.TeamFoundation.TestManagement.WebApi;

I am not using any RestAPI queries for now. Only these pre-designed methods from mentioned libs (I know that they are using Rest service in the background) and I hope that I can somehow manage to do it with these methods. Is there a way to do so?

Thanks for possible solutions

Apuna12
  • 375
  • 2
  • 6
  • 23

1 Answers1

4

It looks like the GetTestResultsByBuildAsync method of the TestManagementHttpClient class is what you're looking for. It returns a list of ShallowTestCaseResult instances. It contains very basic info about each test run, but you can use the Id of each entity in that list and feed it to the GetTestResultByIdAsync method, which returns the full info about the test result.

If there are lots of results, you might want to obtain them page by page. In this case, use the GetTestResultsByBuildAsync2 method (note 2 at the end of the method name). It returns the paged list collection, which contains the ContinuationToken property.

When you request the first Top results, that property will hold the continuation token, in case there are more results to return. You should supply that token to the subsequent call. Repeat that until the continuation token is null in the resulting collection.

Yan Sklyarenko
  • 31,557
  • 24
  • 104
  • 139
  • 1
    Hello @Yan . GetTestResultsByBuildAsync() only has 10000 records instead of 54k. Is there a way to get all of them? It seems that buffer maximum is set to 10k. Is it possible to somehow raise it? By the way thanks for the answer. – Apuna12 Oct 11 '21 at 08:53
  • 1
    @Apuna12 I've updated my answer with the info about the methods to use in order to get paged results. – Yan Sklyarenko Oct 11 '21 at 09:31
  • I am hitting authentication errors when using the `GetTestResultsByBuildAsync2` method. I am using an Azure DevOps PAT scoped to read & execute builds as well as read & write tests. Is there anything else I need? – Sunny-Dee Mar 03 '22 at 23:00