private void ProcessXml() { // Determine the part of the xmloutput string to parse // In some cases Catch2 output contains additional lines of output after the // xml-output. The XmlDocument parser doesn't like this so let's make sure those // extra lines are ignored. var cleanedoutput = XmlOutput.CleanXml(Xml); if (string.IsNullOrEmpty(cleanedoutput)) { // Looks like we have a partial result. // Let's try to process as much as possible ProcessXmlPartial(); return; } try { // Parse the Xml document var xml = new XmlDocument(); xml.LoadXml(cleanedoutput); if (XmlOutput.IsVersion2Xml(cleanedoutput)) { var nodeGroup = xml.SelectSingleNode("Catch/Group"); ExtractTestResults(nodeGroup); return; } else if (XmlOutput.IsVersion3Xml(cleanedoutput)) { var nodeGroup = xml.SelectSingleNode("Catch2TestRun"); ExtractTestResults(nodeGroup); return; } } catch { // Someting went wrong parsing the XML // Treat as partial result and try to parse as much as possible TestResults.Clear(); // Cleanup any TestResults that may already have been processed } // Looks like we have a corrupted/partial result. // Let's try to process as much as possible ProcessXmlPartial(); }
private void ProcessXml() { try { // Determine the part of the xmloutput string to parse // In some cases Catch2 output contains additional lines of output after the // xml-output. The XmlDocument parser doesn't like this so let's make sure those // extra lines are ignored. var cleanedoutput = XmlOutput.CleanXml(_xmloutput); if (string.IsNullOrEmpty(cleanedoutput)) { SetInvalidTestRunnerOutput(); return; } // Parse the Xml document var xml = new XmlDocument(); xml.LoadXml(cleanedoutput); if (XmlOutput.IsVersion2Xml(cleanedoutput)) { var nodeGroup = xml.SelectSingleNode("Catch/Group"); ExtractTestResult(nodeGroup); } else if (XmlOutput.IsVersion3Xml(cleanedoutput)) { var nodeGroup = xml.SelectSingleNode("Catch2TestRun"); ExtractTestResult(nodeGroup); } } catch { SetInvalidTestRunnerOutput(); } }