/// <summary> /// Builds a new TestSuite. Starts a new context in which /// newly created TestUnits will be parented to this TestSuite. /// </summary> /// <param name="name">Test Suite Name</param> /// <param name="id">Test Suite Id</param> /// <returns>this</returns> public TestFrameworkBuilder TestSuite(string name, int? id) { TestSuite testSuite = new TestSuite(name, this.Parent); testSuite.Id = id; this.Parent = testSuite; return this; }
public void Visit(TestSuite testSuite) { Code.Require(testSuite, "testSuite"); if (ShouldVisit(testSuite)) { foreach (TestUnit child in testSuite.Children) { child.Apply(this); } } }
/// <summary> /// Parses child TestUnit nodes. /// </summary> /// <param name="nav">The parent XPathNavigator which hosts TestUnit nodes.</param> /// <param name="parent">The parent TestSuite to which TestUnits are attached to.</param> /// <param name="collection">The TestResultCollection which will host the result.</param> private static void ParseTestUnitsReport(XPathNavigator nav, TestSuite parent, TestResultCollection collection) { foreach (XPathNavigator child in nav.SelectChildren(Xml.TestSuite, string.Empty)) { ParseTestSuiteReport(child, parent, collection); } foreach (XPathNavigator child in nav.SelectChildren(Xml.TestCase, string.Empty)) { ParseTestCaseReport(child, parent, collection); } }
public void ReadXml(XmlReader reader) { Utility.Code.Require(reader, "reader"); reader.MoveToElement(); this.Source = reader.GetAttribute(Xml.Source); bool empty = reader.IsEmptyElement; reader.ReadStartElement(Xml.BoostTestFramework); if (!empty) { XmlSerializer deserialiser = new XmlSerializer(typeof(TestSuite)); this.MasterTestSuite = deserialiser.Deserialize(reader) as TestSuite; reader.ReadEndElement(); } }
public void Visit(TestSuite testSuite) { Utility.Code.Require(testSuite, "testSuite"); foreach (TestUnit unit in testSuite.Children) { unit.Apply(this); } }
public void Visit(TestSuite testSuite) { Utility.Code.Require(testSuite, "testSuite"); this.TestSuite.Push(testSuite); // Identify Master Test Suite if ((this.MasterTestSuite == null) && (testSuite.Parent == null)) { this.MasterTestSuite = testSuite; } foreach (TestUnit child in testSuite.Children) { child.Apply(this); } this.TestSuite.Pop(); }
public TestFramework(string source, TestSuite master) { this.Source = source; this.MasterTestSuite = master; }
/// <summary> /// Constructor /// </summary> /// <param name="name">Test Unit (local) name.</param> /// <param name="parent">Parent/Owner Test Unit of this instance.</param> public TestCase(string name, TestSuite parent) : base(name, parent) { }
/// <summary> /// Given a fully qualified name of a <b>test case</b>, generates the respective test unit hierarchy. /// </summary> /// <param name="fullyQualifiedName">The fully qualified name of the <b>test case</b></param> /// <returns>The test case hierarchy represented by the provided fully qualified name</returns> /// <remarks>The parameter 'fullyQualifiedName' will be modified and emptied in due process</remarks> private static TestCase FromFullyQualifiedName(QualifiedNameBuilder fullyQualifiedName) { // Reverse the fully qualified name stack i.e. Master Test Suite should be first element and Test Case should be last element Stack<string> hierarchy = new Stack<string>(); while (fullyQualifiedName.Peek() != null) { hierarchy.Push(fullyQualifiedName.Peek()); fullyQualifiedName.Pop(); } TestSuite parent = null; // Treat each entry (except for the last) as a test suite while (hierarchy.Count > 1) { parent = new TestSuite(hierarchy.Peek(), parent); hierarchy.Pop(); } // Treat the last entry as a test case return (hierarchy.Count == 1) ? new TestCase(hierarchy.Peek(), parent) : null; }
public void Visit(TestSuite testSuite) { this.SuiteSerializer.Serialize(this.Writer, testSuite); }
/// <summary> /// Constructor /// </summary> /// <param name="name">Test Unit (local) name.</param> /// <param name="parent">Parent/Owner Test Unit of this instance.</param> public TestSuite(string name, TestSuite parent) : base(name, parent) { this._children = new List<TestUnit>(); }
public TestFrameworkBuilder TestSuite(string name, int? id, SourceFileInfo source, bool enabled) { TestSuite testSuite = new TestSuite(name, this.Parent); testSuite.Id = id; testSuite.Source = source; this.Parent = testSuite; testSuite.DefaultEnabled = enabled; return this; }
/// <summary> /// Ends the current TestSuite context and moves up one level in the hierarchy. /// </summary> /// <returns>this</returns> public TestFrameworkBuilder EndSuite() { this.Parent = (TestSuite)this.Parent.Parent; return(this); }
/// <summary> /// Ends the current TestSuite context and moves up one level in the hierarchy. /// </summary> /// <returns>this</returns> public TestFrameworkBuilder EndSuite() { this.Parent = (TestSuite)this.Parent.Parent; return this; }
/// <summary> /// Parses a TestCase node. /// </summary> /// <param name="node">The XPathNavigator pointing to a TestCase node.</param> /// <param name="parent">The parent TestSuite to which TestUnits are attached to.</param> /// <param name="collection">The TestResultCollection which will host the result.</param> private static void ParseTestCaseReport(XPathNavigator node, TestSuite parent, TestResultCollection collection) { TestCase testCase = new TestCase(node.GetAttribute(Xml.Name, string.Empty), parent); collection[testCase] = ParseTestResult(node, testCase, collection); }
/// <summary> /// Builds a new TestSuite. Starts a new context in which /// newly created TestUnits will be parented to this TestSuite. /// </summary> /// <param name="name">Test Suite Name</param> /// <param name="id">Test Suite Id</param> /// <param name="source">Test Suite source file debug information</param> /// <returns>this</returns> public TestFrameworkBuilder TestSuite(string name, int? id, SourceFileInfo source) { TestSuite testSuite = new TestSuite(name, this.Parent); testSuite.Id = id; testSuite.Source = source; this.Parent = testSuite; return this; }
/// <summary> /// States whether the provided test suite should be visited /// </summary> /// <param name="unit">The test suite under consideration</param> /// <returns>true if the provided TestSuite should be visited; false otherwise</returns> protected virtual bool ShouldVisit(TestSuite suite) { return true; }
/// <summary> /// Parses a TestCase node. /// </summary> /// <param name="node">The XPathNavigator pointing to a TestCase node.</param> /// <param name="parent">The parent TestSuite to which TestUnits are attached to.</param> /// <param name="collection">The TestResultCollection which will host the result.</param> private static void ParseTestCaseReport(XPathNavigator node, TestSuite parent, TestResultCollection collection) { QualifiedNameBuilder fullname = new QualifiedNameBuilder(parent); fullname.Push(node.GetAttribute(Xml.Name, string.Empty)); TestCase testCase = null; // If the test is already available, reuse it TestResult current = collection[fullname.ToString()]; if (current != null) { testCase = current.Unit as TestCase; } // Else construct and add it to the appropriate parent if (testCase == null) { testCase = new TestCase(fullname.Peek(), parent); } TestResult result = ParseTestResult(node, testCase, collection); // Aggregate results. Common use-case in BOOST_DATA_TEST_CASE. collection[fullname.ToString()] = Aggregate(result, current); }
protected override bool ShouldVisit(TestSuite suite) { return false; }
/// <summary> /// Constructor /// </summary> /// <param name="name">Test Unit (local) name.</param> /// <param name="parent">Parent/Owner Test Unit of this instance.</param> public TestSuite(string name, TestSuite parent) : base(name, parent) { this._children = new List <TestUnit>(); }