private static void ExtractTestFixtures(NUnitDiscoveryCanHaveTestFixture parent, XElement node) { foreach (var child in node.Elements()) { var type = child.Attribute(NUnitXmlAttributeNames.Type).Value; var className = child.Attribute(NUnitXmlAttributeNames.Classname)?.Value; var btf = ExtractSuiteBasePropertiesClass(child); switch (type) { case "TestFixture": var tf = new NUnitDiscoveryTestFixture(btf, className, parent); parent.AddTestFixture(tf); ExtractTestCases(tf, child); ExtractParameterizedMethodsAndTheories(tf, child); break; case "TestSuite": var ts = ExtractTestSuite(child, parent); parent.AddTestSuite(ts); if (child.HasElements) { ExtractAllFixtures(ts, child); } break; default: throw new DiscoveryException($"Not a TestFixture or TestSuite, but {type}"); } } }
public static NUnitDiscoveryTestFixture ExtractTestFixture(INUnitDiscoveryCanHaveTestFixture parent, XElement node, string className) { var b = ExtractSuiteBasePropertiesClass(node); var ts = new NUnitDiscoveryTestFixture(b, className, parent); return(ts); }
private static void ExtractTestFixtures(NUnitDiscoveryCanHaveTestFixture parent, XElement node) { foreach (var child in node.Elements()) { var type = child.Attribute(NUnitXmlAttributeNames.Type).Value; var className = child.Attribute(NUnitXmlAttributeNames.Classname)?.Value; var btf = ExtractSuiteBasePropertiesClass(child); if (type != "TestFixture") { throw new DiscoveryException($"Not a TestFixture, but {type}"); } var tf = new NUnitDiscoveryTestFixture(btf, className, parent); parent.AddTestFixture(tf); ExtractTestCases(tf, child); ExtractParameterizedMethodsAndTheories(tf, child); } }
private static void ExtractParameterizedMethodsAndTheories(NUnitDiscoveryTestFixture tf, XElement node) { const string parameterizedMethod = "ParameterizedMethod"; const string theory = "Theory"; foreach (var child in node.Elements("test-suite")) { var type = child.Attribute(NUnitXmlAttributeNames.Type)?.Value; if (type != parameterizedMethod && type != "Theory" && type != "GenericMethod") { throw new DiscoveryException($"Expected ParameterizedMethod, Theory or GenericMethod, but was {type}"); } var className = child.Attribute(NUnitXmlAttributeNames.Classname)?.Value; var btf = ExtractSuiteBasePropertiesClass(child); switch (type) { case parameterizedMethod: { var tc = new NUnitDiscoveryParameterizedMethod(btf, className, tf); ExtractTestCases(tc, child); tf.AddParameterizedMethod(tc); break; } case theory: { var tc = new NUnitDiscoveryTheory(btf, className, tf); tf.AddTheory(tc); ExtractTestCases(tc, child); break; } default: { var tc = new NUnitDiscoveryGenericMethod(btf, className, tf); tf.AddGenericMethod(tc); ExtractTestCases(tc, child); break; } } } }
public void AddTestFixture(NUnitDiscoveryTestFixture tf) { testFixtures.Add(tf); }