DevOps.Util.DotNet/Extensions.cs
/// <summary>
/// List the set of <see cref="TestCaseResult"/> for a given <see cref="TestRun"/>. 
///
/// Ideally we could include sub results in the ListTestResultsAsync call because it's a supported parameter of
/// the ListTestResults AzDO REST API call. Unfortunately there is a bug right now where they are not respecting 
/// that parameter. 
///
/// As a fallback for now we simply iterate the results, look for ones that are likely theories, and then request the 
/// results individually. This means we also limit to only failed outcomes bc otherwise we'd be making an additional
/// API call for every single result. That could be extremely expensive
/// </summary>
List the set of  for a given .

Ideally we could include sub results in the ListTestResultsAsync call because it's a supported parameter of
the ListTestResults AzDO REST API call. Unfortunately there is a bug right now where they are not respecting
that parameter.

As a fallback for now we simply iterate the results, look for ones that are likely theories, and then request the
results individually. This means we also limit to only failed outcomes bc otherwise we'd be making an additional
API call for every single result. That could be extremely expensive
List the set of for a given . Ideally we could include sub results in the ListTestResultsAsync call because it ' s a supported parameter of the ListTestResults AzDO REST API call . Unfortunately there is a bug right now where they are not respecting that parameter . As a fallback for now we simply iterate the results look for ones that are likely theories and then request the results individually . This means we also limit to only failed outcomes bc otherwise we ' d be making an additional API call for every single result . That could be extremely expensive
public static async Task<List<TestCaseResult>> ListTestResultsAsync(
            this DevOpsServer server,
            string project,
            int testRunId,
            TestOutcome[]? outcomes,
            bool includeSubResults,
            Action<Exception>? onError = null)
        {
            var testCaseResults = await server.ListTestResultsAsync(project, testRunId, outcomes: outcomes).ConfigureAwait(false);
            if (includeSubResults)
            {
                var comparer = StringComparer.OrdinalIgnoreCase;
                for (int i = 0; i < testCaseResults.Count; i++)
                {
                    var testCaseResult = testCaseResults[i];
                    if (string.IsNullOrEmpty(testCaseResult.ErrorMessage) && IsFailedOutcome(testCaseResult.Outcome))
                    {
                        try
                        {
                            var otherResult = await server.GetTestCaseResultAsync(project, testRunId, testCaseResult.Id, ResultDetail.SubResults).ConfigureAwait(false);
                            if (otherResult.SubResults is object)
                            {
                                otherResult.SubResults = otherResult
                                    .SubResults
                                    .Where(x => IsFailedOutcome(x.Outcome))
                                    .ToArray();
                            }
                            testCaseResults[i] = otherResult;
                        }
                        catch (Exception ex)
                        {
                            onError?.Invoke(ex);
                        }
                    }
                    bool IsFailedOutcome(string outcome) => DotNetUtil.FailedTestOutcomes.Any(x => comparer.Equals(x.ToString(), outcome));
                }
            }
            return testCaseResults;
        }
public static async Task < List < TestCaseResult > > ListTestResultsAsync ( this DevOpsServer server , string project , int testRunId , TestOutcome [ ] ? outcomes , bool includeSubResults , Action < Exception > ? onError = null ) { var testCaseResults = await server . ListTestResultsAsync ( project , testRunId , outcomes : outcomes ) . ConfigureAwait ( false ) ; if ( includeSubResults ) { var comparer = StringComparer . OrdinalIgnoreCase ; for ( int i = 0 ; i < testCaseResults . Count ; i ++ ) { var testCaseResult = testCaseResults [ i ] ; if ( string . IsNullOrEmpty ( testCaseResult . ErrorMessage ) && IsFailedOutcome ( testCaseResult . Outcome ) ) { try { var otherResult = await server . GetTestCaseResultAsync ( project , testRunId , testCaseResult . Id , ResultDetail . SubResults ) . ConfigureAwait ( false ) ; if ( otherResult . SubResults is object ) { otherResult . SubResults = otherResult . SubResults . Where ( x => IsFailedOutcome ( x . Outcome ) ) . ToArray ( ) ; } testCaseResults [ i ] = otherResult ; } catch ( Exception ex ) { onError ? . Invoke ( ex ) ; } } bool IsFailedOutcome ( string outcome ) => DotNetUtil . FailedTestOutcomes . Any ( x => comparer . Equals ( x . ToString ( ) , outcome ) ) ; } } return testCaseResults ; }
List the set of  for a given .
List the set of for a given .
// If we can't fetch the sub-result then just continue
DevOpsServer
this
project
string
testRunId
int
outcomes
TestOutcome[]?
includeSubResults
bool
onError
Action<Exception>?