Skip to content

Commit c289d4e

Browse files
committed
NIT Changes
1 parent 842f4d8 commit c289d4e

1 file changed

Lines changed: 25 additions & 19 deletions

File tree

src/Agent.Worker/TestResults/ResultsCommandExtension.cs

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -85,24 +85,22 @@ public void Execute(IExecutionContext context, Command command)
8585
var executionContext = _executionContext;
8686
var testResultFiles = _testResultFiles;
8787
var testRunner = _testRunner;
88-
var mergeResults = _mergeResults;
89-
var runTitle = _runTitle;
90-
var publishRunLevelAttachments = _publishRunLevelAttachments;
9188
var testCaseResults = _testCaseResults;
9289
var testPlanId = _testPlanId;
90+
var runTitle = _runTitle;
9391
var publishTestResultsLibFeatureState = _publishTestResultsLibFeatureState;
9492
var triggerCoverageMergeJobFeatureState = _triggerCoverageMergeJobFeatureState;
9593
var failTaskOnFailedTests = _failTaskOnFailedTests;
94+
var publishOptions = GetPublishOptions();
9695
var telemetryProperties = _telemetryProperties;
9796

9897
var commandContext = context.GetHostContext().CreateService<IAsyncCommandContext>();
9998
commandContext.InitializeCommandContext(context, StringUtil.Loc("PublishTestResults"));
10099
commandContext.Task = PublishTestRunDataAsync(
101-
executionContext, teamProject, runContext,
102-
testResultFiles, testRunner, mergeResults, runTitle,
103-
publishRunLevelAttachments, testCaseResults, testPlanId,
104-
publishTestResultsLibFeatureState, triggerCoverageMergeJobFeatureState,
105-
failTaskOnFailedTests, telemetryProperties);
100+
teamProject, runContext, executionContext, testResultFiles, testRunner,
101+
testCaseResults, testPlanId, runTitle, publishTestResultsLibFeatureState,
102+
triggerCoverageMergeJobFeatureState, failTaskOnFailedTests,
103+
publishOptions, telemetryProperties);
106104
executionContext.AsyncCommands.Add(commandContext);
107105
}
108106

@@ -313,23 +311,31 @@ private TestRunContext CreateTestRunContext()
313311

314312
}
315313

316-
private PublishOptions GetPublishOptions(bool publishRunLevelAttachments)
314+
private PublishOptions GetPublishOptions()
317315
{
318316
var publishOptions = new PublishOptions()
319317
{
320318
IsMergeTestResultsToSingleRun = _mergeResults,
321-
IsAddTestRunAttachments = publishRunLevelAttachments
319+
IsAddTestRunAttachments = _publishRunLevelAttachments
322320
};
323321

324322
return publishOptions;
325323
}
326324

327325
private async Task PublishTestRunDataAsync(
328-
IExecutionContext executionContext, string teamProject, TestRunContext testRunContext,
329-
List<string> testResultFiles, string testRunner, bool mergeResults, string runTitle,
330-
bool publishRunLevelAttachments, TestCaseResult[] testCaseResults, string testPlanId,
331-
bool publishTestResultsLibFeatureState, bool triggerCoverageMergeJobFeatureState,
332-
bool failTaskOnFailedTests, Dictionary<string, object> telemetryProperties)
326+
string teamProject,
327+
TestRunContext testRunContext,
328+
IExecutionContext executionContext,
329+
List<string> testResultFiles,
330+
string testRunner,
331+
TestCaseResult[] testCaseResults,
332+
string testPlanId,
333+
string runTitle,
334+
bool publishTestResultsLibFeatureState,
335+
bool triggerCoverageMergeJobFeatureState,
336+
bool failTaskOnFailedTests,
337+
PublishOptions publishOptions,
338+
Dictionary<string, object> telemetryProperties)
333339
{
334340
bool isTestRunOutcomeFailed = false;
335341

@@ -345,19 +351,19 @@ private async Task PublishTestRunDataAsync(
345351

346352
if (!testCaseResults.IsNullOrEmpty() && !testPlanId.IsNullOrEmpty())
347353
{
348-
isTestRunOutcomeFailed = await publisher.PublishAsync(testRunContext, testResultFiles, testCaseResults, GetPublishOptions(publishRunLevelAttachments), executionContext.CancellationToken);
354+
isTestRunOutcomeFailed = await publisher.PublishAsync(testRunContext, testResultFiles, testCaseResults, publishOptions, executionContext.CancellationToken);
349355
}
350356
else
351357
{
352-
isTestRunOutcomeFailed = await publisher.PublishAsync(testRunContext, testResultFiles, GetPublishOptions(publishRunLevelAttachments), executionContext.CancellationToken);
358+
isTestRunOutcomeFailed = await publisher.PublishAsync(testRunContext, testResultFiles, publishOptions, executionContext.CancellationToken);
353359
}
354360
}
355361
else
356362
{
357363
var publisher = executionContext.GetHostContext().CreateService<ILegacyTestRunDataPublisher>();
358-
publisher.InitializePublisher(executionContext, teamProject, connection, testRunner, publishRunLevelAttachments);
364+
publisher.InitializePublisher(executionContext, teamProject, connection, testRunner, publishOptions.IsAddTestRunAttachments);
359365

360-
isTestRunOutcomeFailed = await publisher.PublishAsync(testRunContext, testResultFiles, runTitle, executionContext.Variables.Build_BuildId, mergeResults);
366+
isTestRunOutcomeFailed = await publisher.PublishAsync(testRunContext, testResultFiles, runTitle, executionContext.Variables.Build_BuildId, publishOptions.IsMergeTestResultsToSingleRun);
361367
}
362368

363369
if (isTestRunOutcomeFailed && failTaskOnFailedTests)

0 commit comments

Comments
 (0)