Skip to content

Commit

Permalink
[rel/3.5] Fix ResultFiles placement in TRX report (#3264)
Browse files Browse the repository at this point in the history
  • Loading branch information
nohwnd authored Jul 15, 2024
1 parent 5a7bb00 commit 0dd4f1c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,12 @@ private void AddResults(string testAppModule, XElement testRun, out XElement tes
output.Add(errorInfoElement);
}

// add collectorDataEntries details
if (output.HasElements && outcome != "NotExecuted")
{
unitTestResult.Add(output);
}

if (_artifactsByTestNode.TryGetValue(testNode.Uid, out List<SessionFileArtifact>? fileArtifacts))
{
var resultFiles = new XElement("ResultFiles");
Expand All @@ -536,13 +542,7 @@ private void AddResults(string testAppModule, XElement testRun, out XElement tes
new XAttribute("path", fileArtifact.FileInfo.FullName)));
}

output.Add(resultFiles);
}

// add collectorDataEntries details
if (output.HasElements && outcome != "NotExecuted")
{
unitTestResult.Add(output);
unitTestResult.Add(resultFiles);
}

results.Add(unitTestResult);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,11 +299,9 @@ public async Task TrxReportEngine_GenerateReportAsync_WithArtifactsByTestNode_Tr
string trxContent = xml.ToString();
string trxContentsPattern = @"
<UnitTestResult .* testName=""TestMethod"" .* outcome=""Passed"" .*>
<Output>
<ResultFiles>
<ResultFile path=.*fileName"" />
</ResultFiles>
</Output>
<ResultFiles>
<ResultFile path=.*fileName"" />
</ResultFiles>
</UnitTestResult>
";
Assert.That(Regex.IsMatch(trxContent, trxContentsPattern));
Expand Down

0 comments on commit 0dd4f1c

Please sign in to comment.