From 0dd4f1cfed98e96648f1a13d1a45b9c1cc7a718d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Jare=C5=A1?= Date: Mon, 15 Jul 2024 15:24:16 +0200 Subject: [PATCH] [rel/3.5] Fix ResultFiles placement in TRX report (#3264) --- .../TrxReportEngine.cs | 14 +++++++------- .../TrxTests.cs | 8 +++----- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/Platform/Microsoft.Testing.Extensions.TrxReport/TrxReportEngine.cs b/src/Platform/Microsoft.Testing.Extensions.TrxReport/TrxReportEngine.cs index 383e0c58fe..d80c658f8e 100644 --- a/src/Platform/Microsoft.Testing.Extensions.TrxReport/TrxReportEngine.cs +++ b/src/Platform/Microsoft.Testing.Extensions.TrxReport/TrxReportEngine.cs @@ -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? fileArtifacts)) { var resultFiles = new XElement("ResultFiles"); @@ -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); diff --git a/test/UnitTests/Microsoft.Testing.Extensions.UnitTests/TrxTests.cs b/test/UnitTests/Microsoft.Testing.Extensions.UnitTests/TrxTests.cs index debc96de07..de0012aec3 100644 --- a/test/UnitTests/Microsoft.Testing.Extensions.UnitTests/TrxTests.cs +++ b/test/UnitTests/Microsoft.Testing.Extensions.UnitTests/TrxTests.cs @@ -299,11 +299,9 @@ public async Task TrxReportEngine_GenerateReportAsync_WithArtifactsByTestNode_Tr string trxContent = xml.ToString(); string trxContentsPattern = @" - - - - - + + + "; Assert.That(Regex.IsMatch(trxContent, trxContentsPattern));