public async Task <bool> PublishAsync(TestRunContext runContext, List <string> testResultFiles, PublishOptions publishOptions, CancellationToken cancellationToken = default(CancellationToken)) { try { TestDataProvider testDataProvider = ParseTestResultsFile(runContext, testResultFiles); var publishTasks = new List <Task>(); if (testDataProvider != null) { var testRunData = testDataProvider.GetTestRunData(); //publishing run level attachment publishTasks.Add(Task.Run(() => _testRunPublisher.PublishTestRunDataAsync(runContext, _projectName, testRunData, publishOptions, cancellationToken))); //publishing build level attachment publishTasks.Add(Task.Run(() => UploadBuildDataAttachment(runContext, testDataProvider.GetBuildData(), cancellationToken))); await Task.WhenAll(publishTasks); return(GetTestRunOutcome(testRunData)); } return(false); } catch (Exception ex) { _executionContext.Warning("Failed to publish test run data: " + ex.ToString()); } return(false); }
public async Task <bool> PublishAsync(TestRunContext runContext, List <string> testResultFiles, PublishOptions publishOptions, CancellationToken cancellationToken = default(CancellationToken)) { try { TestDataProvider testDataProvider = ParseTestResultsFile(runContext, testResultFiles); var publishTasks = new List <Task>(); if (testDataProvider != null) { var testRunData = testDataProvider.GetTestRunData(); //publishing run level attachment Task <IList <TestRun> > publishtestRunDataTask = Task.Run(() => _testRunPublisher.PublishTestRunDataAsync(runContext, _projectName, testRunData, publishOptions, cancellationToken)); Task uploadBuildDataAttachmentTask = Task.Run(() => UploadBuildDataAttachment(runContext, testDataProvider.GetBuildData(), cancellationToken)); publishTasks.Add(publishtestRunDataTask); //publishing build level attachment publishTasks.Add(uploadBuildDataAttachmentTask); await Task.WhenAll(publishTasks); IList <TestRun> publishedRuns = publishtestRunDataTask.Result; _calculateTestRunSummary = _featureFlagService.GetFeatureFlagState(TestResultsConstants.CalculateTestRunSummaryFeatureFlag, TestResultsConstants.TFSServiceInstanceGuid); var isTestRunOutcomeFailed = GetTestRunOutcome(_executionContext, testRunData, out TestRunSummary testRunSummary); // Storing testrun summary in environment variable, which will be read by PublishPipelineMetadataTask and publish to evidence store. if (_calculateTestRunSummary) { TestResultUtils.StoreTestRunSummaryInEnvVar(_executionContext, testRunSummary, _testRunner, "PublishTestResults"); } // Check failed results for flaky aware // Fallback to flaky aware if there are any failures. bool isFlakyCheckEnabled = _featureFlagService.GetFeatureFlagState(TestResultsConstants.EnableFlakyCheckInAgentFeatureFlag, TestResultsConstants.TCMServiceInstanceGuid); if (isTestRunOutcomeFailed && isFlakyCheckEnabled) { var runOutcome = _testRunPublisherHelper.CheckRunsForFlaky(publishedRuns, _projectName); if (runOutcome != null && runOutcome.HasValue) { isTestRunOutcomeFailed = runOutcome.Value; } } return(isTestRunOutcomeFailed); } return(false); } catch (Exception ex) { _executionContext.Warning("Failed to publish test run data: " + ex.ToString()); } return(false); }
public async Task <bool> PublishAsync(TestRunContext runContext, List <string> testResultFiles, PublishOptions publishOptions, CancellationToken cancellationToken = default(CancellationToken)) { try { TestDataProvider testDataProvider = ParseTestResultsFile(runContext, testResultFiles); var publishTasks = new List <Task>(); if (testDataProvider != null) { var testRunData = testDataProvider.GetTestRunData(); //publishing run level attachment publishTasks.Add(Task.Run(() => _testRunPublisher.PublishTestRunDataAsync(runContext, _projectName, testRunData, publishOptions, cancellationToken))); //publishing build level attachment publishTasks.Add(Task.Run(() => UploadBuildDataAttachment(runContext, testDataProvider.GetBuildData(), cancellationToken))); await Task.WhenAll(publishTasks); _calculateTestRunSummary = _featureFlagService.GetFeatureFlagState(TestResultsConstants.CalculateTestRunSummaryFeatureFlag, TestResultsConstants.TFSServiceInstanceGuid); var runOutcome = GetTestRunOutcome(_executionContext, testRunData, out TestRunSummary testRunSummary); // Storing testrun summary in environment variable, which will be read by PublishPipelineMetadataTask and publish to evidence store. if (_calculateTestRunSummary) { TestResultUtils.StoreTestRunSummaryInEnvVar(_executionContext, testRunSummary, _testRunner, "PublishTestResults"); } return(runOutcome); } return(false); } catch (Exception ex) { _executionContext.Warning("Failed to publish test run data: " + ex.ToString()); } return(false); }