Skip to content

Commit

Permalink
Replaced manual depth w/ XmlReader Depth.
Browse files Browse the repository at this point in the history
  • Loading branch information
xkbeyer committed Jul 23, 2018
1 parent 1c3862c commit 17c6467
Showing 1 changed file with 7 additions and 21 deletions.
28 changes: 7 additions & 21 deletions TestAdapter/TestExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,12 @@ public void RunTests(IEnumerable<TestCase> testsToRun, IRunContext runContext, I
System.IO.File.Delete(caseFile);
}

/// <summary>
/// Reports all results from the XML output to the framework.
/// </summary>
/// <param name="output_text">The text lines of the output</param>
/// <param name="tests">List of tests from the discoverer</param>
/// <param name="frameworkHandle"></param>
protected virtual void ComposeResults(IList<string> output_text, IList<TestCase> tests, IFrameworkHandle frameworkHandle)
{
var xmlresult = string.Join("", output_text);
Expand All @@ -178,30 +184,10 @@ protected virtual void ComposeResults(IList<string> output_text, IList<TestCase>
try
{
var reader = XmlReader.Create(stream);
int depth = 0;
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.EndElement)
{
if (reader.Name == "Group" || reader.Name == "Catch")
depth--;
if (reader.Depth != 2 || reader.Name != "TestCase")
continue;
}

// only process Element nodes here
if (reader.NodeType != XmlNodeType.Element)
continue;

if ((depth == 0 && reader.Name == "Catch") ||
(depth == 1 && reader.Name == "Group"))
{
depth++;
continue;
}

if (depth != 2 || reader.Name != "TestCase")
continue;

var xmlResult = (Tests.TestCase)testCaseSerializer.Deserialize(reader.ReadSubtree());

// Find the matching test case
Expand Down

0 comments on commit 17c6467

Please sign in to comment.