Skip to content

Commit

Permalink
Merge branch 'master' into feature/dependabot
Browse files Browse the repository at this point in the history
  • Loading branch information
aleks-ivanov committed Dec 25, 2024
2 parents f870670 + 08edb6e commit d0ed5d3
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 9 deletions.
25 changes: 16 additions & 9 deletions src/Agent.Worker/TestResults/TestDataPublisher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,24 +153,31 @@ public void InitializePublisher(IExecutionContext context, string projectName, V

for (testRunDataIterator = 0; testRunDataIterator < testRunData.Count; testRunDataIterator++)
{
var testResultsUpdated = new List<TestCaseResultData>();
for (testResultDataIterator = 0; testResultDataIterator < testRunData[testRunDataIterator].TestResults.Count; testResultDataIterator++)
{
var testResultFQN = testRunData[testRunDataIterator].TestResults[testResultDataIterator].AutomatedTestStorage +
"." + testRunData[testRunDataIterator].TestResults[testResultDataIterator].AutomatedTestName;

if (testResultByFQN.TryGetValue(testResultFQN, out List<TestCaseResult> inputs))
{
testRunData[testRunDataIterator].TestResults[testResultDataIterator].TestPoint = inputs[0].TestPoint;
testRunData[testRunDataIterator].TestResults[testResultDataIterator].TestCaseTitle = inputs[0].TestCaseTitle;
testRunData[testRunDataIterator].TestResults[testResultDataIterator].Configuration = inputs[0].Configuration;
testRunData[testRunDataIterator].TestResults[testResultDataIterator].TestCase = inputs[0].TestCase;
testRunData[testRunDataIterator].TestResults[testResultDataIterator].Owner = inputs[0].Owner;
testRunData[testRunDataIterator].TestResults[testResultDataIterator].State = "5";
testRunData[testRunDataIterator].TestResults[testResultDataIterator].TestCaseRevision = inputs[0].TestCaseRevision;

testResultByFQN[testResultFQN].RemoveAt(0);
foreach (var input in inputs)
{
var testCaseResultDataUpdated = TestResultUtils.CloneTestCaseResultData(testRunData[testRunDataIterator].TestResults[testResultDataIterator]);

testCaseResultDataUpdated.TestPoint = input.TestPoint;
testCaseResultDataUpdated.TestCaseTitle = input.TestCaseTitle;
testCaseResultDataUpdated.Configuration = input.Configuration;
testCaseResultDataUpdated.TestCase = input.TestCase;
testCaseResultDataUpdated.Owner = input.Owner;
testCaseResultDataUpdated.State = "5";
testCaseResultDataUpdated.TestCaseRevision = input.TestCaseRevision;

testResultsUpdated.Add(testCaseResultDataUpdated);
}
}
}
testRunData[testRunDataIterator].TestResults = testResultsUpdated;
}
}

Expand Down
57 changes: 57 additions & 0 deletions src/Agent.Worker/TestResults/Utils/TestResultUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
using System;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using Microsoft.TeamFoundation.TestClient.PublishTestResults;
using System.Linq;

namespace Microsoft.VisualStudio.Services.Agent.Worker.TestResults.Utils
{
Expand Down Expand Up @@ -32,6 +34,61 @@ public static void StoreTestRunSummaryInEnvVar(IExecutionContext executionContex
}
}

public static TestCaseResultData CloneTestCaseResultData(TestCaseResultData original)
{
return new TestCaseResultData
{
Id = original.Id,
Comment = original.Comment,
Configuration = original.Configuration,
Project = original.Project,
StartedDate = original.StartedDate,
CompletedDate = original.CompletedDate,
DurationInMs = original.DurationInMs,
Outcome = original.Outcome,
Revision = original.Revision,
State = original.State,
TestCase = original.TestCase,
TestPoint = original.TestPoint,
TestRun = original.TestRun,
ResolutionStateId = original.ResolutionStateId,
ResolutionState = original.ResolutionState,
LastUpdatedDate = original.LastUpdatedDate,
Priority = original.Priority,
ComputerName = original.ComputerName,
ResetCount = original.ResetCount,
Build = original.Build,
Release = original.Release,
ErrorMessage = original.ErrorMessage,
CreatedDate = original.CreatedDate,
IterationDetails = original.IterationDetails?.ToList(),
AssociatedBugs = original.AssociatedBugs?.ToList(),
Url = original.Url,
FailureType = original.FailureType,
AutomatedTestName = original.AutomatedTestName,
AutomatedTestStorage = original.AutomatedTestStorage,
AutomatedTestType = original.AutomatedTestType,
AutomatedTestTypeId = original.AutomatedTestTypeId,
AutomatedTestId = original.AutomatedTestId,
Area = original.Area,
TestCaseTitle = original.TestCaseTitle,
StackTrace = original.StackTrace,
CustomFields = original.CustomFields?.ToList(),
BuildReference = original.BuildReference,
ReleaseReference = original.ReleaseReference,
TestPlan = original.TestPlan,
TestSuite = original.TestSuite,
TestCaseReferenceId = original.TestCaseReferenceId,
Owner = original.Owner,
RunBy = original.RunBy,
LastUpdatedBy = original.LastUpdatedBy,
ResultGroupType = original.ResultGroupType,
TestCaseRevision = original.TestCaseRevision,
TestCaseSubResultData = original.TestCaseSubResultData?.ToList(),
AttachmentData = original.AttachmentData
};
}

private static string GetEvidenceStoreMetadata(IExecutionContext executionContext, TestRunSummary testRunSummary, string testRunner, string name, string description)
{
string evidenceStoreMetadataString = string.Empty;
Expand Down

0 comments on commit d0ed5d3

Please sign in to comment.