private TestSuite AddSuite(XmlNode node) { string name = node.Attributes.Count > 0 && node.Attributes[0].InnerText != null && node.Attributes[0].InnerText != string.Empty ? node.Attributes[0].InnerText : "<<Test Suite>>"; TestSuite suite = new TestSuite(name, string.Empty); foreach (XmlNode n in node.ChildNodes) { if (n.Name == "testsuite") { suite.UnderSuits.Add(AddSuite(n)); } else if (n.Name == "testcase") { suite.AddTestCase(AddCase(n)); } else if (n.Name == "details") { suite.Description = n.Value; } } return(suite); }
public override bool Visit(CodeElement element) { bool visitChildren; switch (element.Kind) { case vsCMElement.vsCMElementNamespace: visitChildren = true; currentSuite = null; break; case vsCMElement.vsCMElementClass: /* * Only visit a class's or struct's children if it inherits * from the CxxTest suite class. */ visitChildren = IsClassTestSuite((VCCodeClass)element); if (visitChildren) { TestCaseCollector collector = new TestCaseCollector(); collector.Process(element.Children); currentSuite.CreateLineNumber = collector.CreateLineNumber; currentSuite.DestroyLineNumber = collector.DestroyLineNumber; foreach (TestCase testCase in collector.TestCases) currentSuite.AddTestCase(testCase); visitChildren = false; } break; case vsCMElement.vsCMElementStruct: /* * Only visit a class's or struct's children if it inherits * from the CxxTest suite class. */ visitChildren = IsStructTestSuite((VCCodeStruct)element); if (visitChildren) { TestCaseCollector collector = new TestCaseCollector(); collector.Process(element.Children); currentSuite.CreateLineNumber = collector.CreateLineNumber; currentSuite.DestroyLineNumber = collector.DestroyLineNumber; foreach (TestCase testCase in collector.TestCases) currentSuite.AddTestCase(testCase); visitChildren = false; } break; case vsCMElement.vsCMElementFunction: visitChildren = false; if (currentSuite == null) { /* * Check global functions to see if the user has created a * main() function. If so, we need to generate the test * runner as a static object instead. */ CheckForMain((VCCodeFunction)element); } break; default: visitChildren = false; break; } return visitChildren; }