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

Merge in references to associated code coverage files #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions TRX_Merger/TRX_Merger.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,12 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="TrxModel\Anchor.cs" />
<Compile Include="TrxModel\Collector.cs" />
<Compile Include="TrxModel\Counters.cs" />
<Compile Include="TrxModel\ErrorInfo.cs" />
<Compile Include="TrxModel\Execution.cs" />
<Compile Include="TrxModel\ResultSummaryOutput.cs" />
<Compile Include="TrxModel\ResultSummary.cs" />
<Compile Include="TrxModel\RunInfo.cs" />
<Compile Include="ReportModel\TestClassReport.cs" />
Expand All @@ -77,6 +80,7 @@
<Compile Include="TrxModel\UnitTestResultOutput.cs" />
<Compile Include="ReportModel\UnitTestResultReport.cs" />
<Compile Include="ReportGenerator\TrxReportGenerator.cs" />
<Compile Include="TrxModel\UriAttachment.cs" />
<Compile Include="Utilities\ExtensionMethods.cs" />
<Compile Include="TestRunMerger.cs" />
<Compile Include="Utilities\TRXSerializationUtils.cs" />
Expand Down
10 changes: 5 additions & 5 deletions TRX_Merger/TestRunMerger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ private static TestRun MergeTestRuns(List<TestRun> testRuns)
DateTime endDate = DateTime.MinValue;




List<UnitTestResult> allResults = new List<UnitTestResult>();
List<UnitTest> allTestDefinitions = new List<UnitTest>();
List<TestEntry> allTestEntries = new List<TestEntry>();
Expand All @@ -58,6 +56,8 @@ private static TestRun MergeTestRuns(List<TestRun> testRuns)
{
Counters = new Counters(),
RunInfos = new List<RunInfo>(),
Output = new ResultSummaryOutput(),
CollectorDataEntries = new List<Collector>()
};
bool resultSummaryPassed = true;

Expand Down Expand Up @@ -100,7 +100,8 @@ private static TestRun MergeTestRuns(List<TestRun> testRuns)
resultSummary.Counters.Timeout += tr.ResultSummary.Counters.Timeout;
resultSummary.Counters.Total += tr.ResultSummary.Counters.Total;
resultSummary.Counters.Warning += tr.ResultSummary.Counters.Warning;

resultSummary.Output.StdOut += tr.ResultSummary.Output.StdOut + Environment.NewLine;
resultSummary.CollectorDataEntries = resultSummary.CollectorDataEntries.Concat(tr.ResultSummary.CollectorDataEntries).ToList();
}

resultSummary.Outcome = resultSummaryPassed ? "Passed" : "Failed";
Expand All @@ -124,7 +125,6 @@ private static TestRun MergeTestRuns(List<TestRun> testRuns)
TestLists = allTestLists,
ResultSummary = resultSummary,
};
}

}
}
}
13 changes: 13 additions & 0 deletions TRX_Merger/TrxModel/Anchor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TRX_Merger.TrxModel
{
public class Anchor
{
public string href { get; set; }
}
}
16 changes: 16 additions & 0 deletions TRX_Merger/TrxModel/Collector.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TRX_Merger.TrxModel
{
public class Collector
{
public string AgentName { get; set; }
public string Uri { get; set; }
public string CollectorDisplayName { get; set; }
public List<UriAttachment> UriAttachments { get; set; }
}
}
2 changes: 2 additions & 0 deletions TRX_Merger/TrxModel/ResultSummary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ public class ResultSummary
{
public string Outcome { get; set; }
public Counters Counters { get; set; }
public ResultSummaryOutput Output { get; set; }
public List<RunInfo> RunInfos { get; set; }
public List<Collector> CollectorDataEntries { get; set; }
}
}
13 changes: 13 additions & 0 deletions TRX_Merger/TrxModel/ResultSummaryOutput.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TRX_Merger.TrxModel
{
public class ResultSummaryOutput
{
public string StdOut { get; set; }
}
}
13 changes: 13 additions & 0 deletions TRX_Merger/TrxModel/UriAttachment.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TRX_Merger.TrxModel
{
public class UriAttachment
{
public Anchor A { get; set; }
}
}
80 changes: 74 additions & 6 deletions TRX_Merger/Utilities/TRXSerializationUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,21 @@ internal static string SerializeAndSaveTestRun(TestRun testRun, string targetPat
new XAttribute("pending", testRun.ResultSummary.Counters.Pending),
new XAttribute("timeout", testRun.ResultSummary.Counters.Timeout),
new XAttribute("total", testRun.ResultSummary.Counters.Total),
new XAttribute("warning", testRun.ResultSummary.Counters.Warning)),
new XElement("RunInfos",
new XAttribute("warning", testRun.ResultSummary.Counters.Warning)),
new XElement("Output",
testRun.ResultSummary.Output == null ? null : new XElement("StdOut", testRun.ResultSummary.Output.StdOut)),
new XElement("CollectorDataEntries",
testRun.ResultSummary.CollectorDataEntries.Select(
cde => new XElement("Collector",
new XAttribute("agentName", cde.AgentName),
new XAttribute("uri", cde.Uri),
new XAttribute("collectorDisplayName", cde.CollectorDisplayName),
new XElement("UriAttachments",
new XElement("UriAttachment", cde.UriAttachments.Select(
ua => new XElement("A",
new XAttribute("href", ua.A.href))
)))))),
new XElement("RunInfos",
testRun.ResultSummary.RunInfos.Select(
ri => new XElement("RunInfo",
new XAttribute("computerName", ri.ComputerName),
Expand Down Expand Up @@ -143,13 +156,68 @@ private static ResultSummary DeserializeResultSummary(XElement resultSummary)
{
Outcome = resultSummary.GetAttributeValue("outcome"),
Counters = DeserializeCounters(resultSummary),
RunInfos = DeserializeRunInfos(resultSummary.Descendants(ns + "RunInfo"))
RunInfos = DeserializeRunInfos(resultSummary.Descendants(ns + "RunInfo")),
Output = DeserializeOutput(resultSummary.Descendants(ns + "Output").FirstOrDefault()),
CollectorDataEntries = DeserializeCollectorDataEntries(resultSummary.Descendants(ns + "Collector"))
};

return res;
}

private static List<RunInfo> DeserializeRunInfos(IEnumerable<XElement> runInfos)
}

private static ResultSummaryOutput DeserializeOutput(XElement output)
{
if (output == null)
return new ResultSummaryOutput();

var stdOut = output.Descendants(ns + "StdOut").FirstOrDefault();

if (stdOut == null)
return new ResultSummaryOutput { StdOut = null };
else
return new ResultSummaryOutput { StdOut = stdOut.Value };
}

private static List<Collector> DeserializeCollectorDataEntries(IEnumerable<XElement> collectorDataEntries)
{
List<Collector> result = new List<Collector>();

foreach (var cde in collectorDataEntries)
{
var agentName = cde.GetAttributeValue("agentName");
var uri = cde.GetAttributeValue("uri");
var collectorDisplayName = cde.GetAttributeValue("collectorDisplayName");

result.Add(new Collector
{
AgentName = agentName,
Uri = uri,
CollectorDisplayName = collectorDisplayName,
UriAttachments = DeserializeUriAttachments(cde.Descendants(ns + "UriAttachment"))
});
}
return result;
}

private static List<UriAttachment> DeserializeUriAttachments(IEnumerable<XElement> uriAttachments)
{
List<UriAttachment> result = new List<UriAttachment>();

foreach (var ua in uriAttachments)
{
result.Add(new UriAttachment
{
A = DeserializeA(ua.Descendants(ns + "A").FirstOrDefault())
});
}
return result;
}

private static Anchor DeserializeA(XElement anchor)
{
return new Anchor { href = anchor.GetAttributeValue("href") };
}

private static List<RunInfo> DeserializeRunInfos(IEnumerable<XElement> runInfos)
{
List<RunInfo> result = new List<RunInfo>();

Expand Down