From 17c6467941e37ead136ae1b3cea12f28844de599 Mon Sep 17 00:00:00 2001 From: Klaus Beyer Date: Mon, 23 Jul 2018 17:52:46 +0200 Subject: [PATCH] Replaced manual depth w/ XmlReader Depth. --- TestAdapter/TestExecutor.cs | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/TestAdapter/TestExecutor.cs b/TestAdapter/TestExecutor.cs index 8df7600..5c9aa08 100644 --- a/TestAdapter/TestExecutor.cs +++ b/TestAdapter/TestExecutor.cs @@ -170,6 +170,12 @@ public void RunTests(IEnumerable testsToRun, IRunContext runContext, I System.IO.File.Delete(caseFile); } + /// + /// Reports all results from the XML output to the framework. + /// + /// The text lines of the output + /// List of tests from the discoverer + /// protected virtual void ComposeResults(IList output_text, IList tests, IFrameworkHandle frameworkHandle) { var xmlresult = string.Join("", output_text); @@ -178,30 +184,10 @@ protected virtual void ComposeResults(IList output_text, IList 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