Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle manual test cases associated with same automated tests #5064

Merged
merged 2 commits into from
Dec 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading