public async Task <TestRunStatistic> GetTestRunSummaryAsync(string projectName, int testRunId, bool allowRetry, CancellationToken cancellationToken) { Trace.Entering(); TestRunStatistic testRunStatistic = null; _executionContext.Debug(string.Format(CultureInfo.CurrentCulture, $"TestRunPublisher.GetTestRunSummaryAsync: Getting test run summary with run id: {testRunId} using new summary api. Allow Retry: {allowRetry}")); if (allowRetry) { var retryHelper = new RetryHelper(_executionContext, MaxRetries); testRunStatistic = await retryHelper.Retry(() => GetTestRunSummaryByOutcome(projectName, testRunId, cancellationToken), (retryCounter) => GetTimeIntervalDelay(retryCounter), (exception) => IsRetriableException(exception)); } else { testRunStatistic = await GetTestRunSummaryByOutcome(projectName, testRunId, cancellationToken); } Trace.Leaving(); return(testRunStatistic); }
public bool IsTestRunFailed(TestRunStatistic testRunStatistics, CancellationToken cancellationToken) { Trace.Entering(); _executionContext.Output(string.Format(CultureInfo.CurrentCulture, "TestRunPublisher.IsTestRunFailed: checking if test run is failed using run summary input")); if (testRunStatistics != null && testRunStatistics.RunStatistics?.Count > 0) { foreach (var stat in testRunStatistics.RunStatistics) { if (stat.Outcome == TestOutcome.Failed.ToString() && stat.Count > 0 && stat.ResultMetadata == ResultMetadata.Flaky) { _executionContext.Output(string.Format(CultureInfo.CurrentCulture, "Number of flaky failed tests is: {0}", stat.Count)); } if (stat.Outcome == TestOutcome.Failed.ToString() && stat.Count > 0 && stat.ResultMetadata != ResultMetadata.Flaky) { _executionContext.Output(string.Format(CultureInfo.CurrentCulture, "Number of failed tests which are non-flaky is: {0}", stat.Count)); return(true); } } } Trace.Leaving(); return(false); }