/// <summary> /// Gets a UNiteTestError Collection for all failed to execute tests. Those test were never run! /// In the case of a fauiler to run, nunit will not give the file name and line location so /// the UnitTestErro object will not have its File property/memeber set /// </summary> /// <param name="xmlNodeList"></param> /// <returns></returns> public static List <UnitTestError> GetFailedExecutionsAsUnitTestErrors(List <XmlNode> xmlNodeList) { List <UnitTestError> lstErros = new List <UnitTestError>(); foreach (XmlNode xmlNode in xmlNodeList) { UnitTestError uterro = new UnitTestError(); //uterro.Text = xmlNode.InnerXml; XmlNode nameNode = xmlNode.Attributes.GetNamedItem("name"); if (nameNode != null) { uterro.Name = nameNode.Value; } //NEW NEW NEW //string regexMessagePattern = @"<message><!\[CDATA\[\s*(?<message>[0-9a-zA-Z_.:,""'\\\s*-]*)\s*\]\]\s*>\s*</message>\s*"; //string regexMessagePattern = @"<message><!\[CDATA\[(?<message>.*)\]\]\s*></message>"; string regexMessagePattern = messageRegexExpresion; System.Text.RegularExpressions.Regex regExMessage = new System.Text.RegularExpressions.Regex(regexMessagePattern); System.Text.RegularExpressions.Match matchMessage = regExMessage.Match(xmlNode.InnerXml); if (matchMessage.Success) { try { uterro.Text = (string)matchMessage.Groups["message"].Value; } catch (Exception ex) { Logger.LogException(ex); } } lstErros.Add(uterro); } return(lstErros); }
public static List <UnitTestError> GetSuccessfulTestSuitesAsUnitTestErrors(List <XmlNode> xmlNodeList) { List <UnitTestError> lstErros = new List <UnitTestError>(); foreach (XmlNode xmlNode in xmlNodeList) { UnitTestError uterro = new UnitTestError(); //uterro.Text = xmlNode.InnerXml; XmlNode nameNode = xmlNode.Attributes.GetNamedItem("name"); if (nameNode != null) { uterro.Name = nameNode.Value; } XmlNode assertsNode = xmlNode.Attributes.GetNamedItem("asserts"); if (assertsNode != null) { uterro.Asserts = assertsNode.Value; } //string regexMessagePattern = @"<message><!\[CDATA\[\s*(?<message>[\w.:,""'\\\s*-`%&_\^@!#><;=\)\(~\$\+/]*)\s*\]\]\s*>\s*</message>\s*"; string regexMessagePattern = messageRegexExpresion; System.Text.RegularExpressions.Regex regExMessage = new System.Text.RegularExpressions.Regex(regexMessagePattern); System.Text.RegularExpressions.Match matchMessage = regExMessage.Match(xmlNode.InnerXml); if (matchMessage.Success) { try { uterro.Text = (string)matchMessage.Groups["message"].Value; } catch (Exception ex) { Logger.LogException(ex); } } //string regexPattern = @"<stack\-trace><!\[CDATA\[at\s*[0-9a-zA-Z_.(),\s*]*\s*in\s*(?<filename>[0-9a-zA-Z_.:,\\\s*]*):line\s(?<line>[0-9]*)"; string regexPattern = stackTraceRegexExpresion; System.Text.RegularExpressions.Regex regEx = new System.Text.RegularExpressions.Regex(regexPattern); System.Text.RegularExpressions.Match match = regEx.Match(xmlNode.InnerXml); if (match.Success) { try { uterro.File = (string)match.Groups["filename"].Value; } catch (Exception ex) { Logger.LogException(ex); } try { uterro.Line = int.Parse((string)match.Groups["line"].Value); } catch (Exception ex) { Logger.LogException(ex); } } else { //FIX ME .cs uterro.File = GetFielNameFromTestCaseElementAttributeName(nameNode.Value) + ".cs"; } lstErros.Add(uterro); } return(lstErros); }
public static List<UnitTestError> GetSuccessfulTestSuitesAsUnitTestErrors(List<XmlNode> xmlNodeList) { List<UnitTestError> lstErros = new List<UnitTestError>(); foreach (XmlNode xmlNode in xmlNodeList) { UnitTestError uterro = new UnitTestError(); //uterro.Text = xmlNode.InnerXml; XmlNode nameNode = xmlNode.Attributes.GetNamedItem("name"); if (nameNode != null) uterro.Name = nameNode.Value; XmlNode assertsNode = xmlNode.Attributes.GetNamedItem("asserts"); if (assertsNode != null) uterro.Asserts = assertsNode.Value; //string regexMessagePattern = @"<message><!\[CDATA\[\s*(?<message>[\w.:,""'\\\s*-`%&_\^@!#><;=\)\(~\$\+/]*)\s*\]\]\s*>\s*</message>\s*"; string regexMessagePattern = messageRegexExpresion; System.Text.RegularExpressions.Regex regExMessage = new System.Text.RegularExpressions.Regex(regexMessagePattern); System.Text.RegularExpressions.Match matchMessage = regExMessage.Match(xmlNode.InnerXml); if (matchMessage.Success) { try { uterro.Text = (string)matchMessage.Groups["message"].Value; } catch (Exception ex) { Logger.LogException(ex); } } //string regexPattern = @"<stack\-trace><!\[CDATA\[at\s*[0-9a-zA-Z_.(),\s*]*\s*in\s*(?<filename>[0-9a-zA-Z_.:,\\\s*]*):line\s(?<line>[0-9]*)"; string regexPattern = stackTraceRegexExpresion; System.Text.RegularExpressions.Regex regEx = new System.Text.RegularExpressions.Regex(regexPattern); System.Text.RegularExpressions.Match match = regEx.Match(xmlNode.InnerXml); if (match.Success) { try { uterro.File = (string)match.Groups["filename"].Value; } catch (Exception ex) { Logger.LogException(ex); } try { uterro.Line = int.Parse((string)match.Groups["line"].Value); } catch (Exception ex) { Logger.LogException(ex); } } else { //FIX ME .cs uterro.File = GetFielNameFromTestCaseElementAttributeName(nameNode.Value) + ".cs"; } lstErros.Add(uterro); } return lstErros; }
/// <summary> /// Gets a UNiteTestError Collection for all failed to execute tests. Those test were never run! /// In the case of a fauiler to run, nunit will not give the file name and line location so /// the UnitTestErro object will not have its File property/memeber set /// </summary> /// <param name="xmlNodeList"></param> /// <returns></returns> public static List<UnitTestError> GetFailedExecutionsAsUnitTestErrors(List<XmlNode> xmlNodeList) { List<UnitTestError> lstErros = new List<UnitTestError>(); foreach (XmlNode xmlNode in xmlNodeList) { UnitTestError uterro = new UnitTestError(); //uterro.Text = xmlNode.InnerXml; XmlNode nameNode = xmlNode.Attributes.GetNamedItem("name"); if (nameNode != null) uterro.Name = nameNode.Value; //NEW NEW NEW //string regexMessagePattern = @"<message><!\[CDATA\[\s*(?<message>[0-9a-zA-Z_.:,""'\\\s*-]*)\s*\]\]\s*>\s*</message>\s*"; //string regexMessagePattern = @"<message><!\[CDATA\[(?<message>.*)\]\]\s*></message>"; string regexMessagePattern = messageRegexExpresion; System.Text.RegularExpressions.Regex regExMessage = new System.Text.RegularExpressions.Regex(regexMessagePattern); System.Text.RegularExpressions.Match matchMessage = regExMessage.Match(xmlNode.InnerXml); if (matchMessage.Success) { try { uterro.Text = (string)matchMessage.Groups["message"].Value; } catch (Exception ex) { Logger.LogException(ex); } } lstErros.Add(uterro); } return lstErros; }