private TestResult SimulateTest( TestNode test, bool ignore ) { if ( test.RunState != RunState.Runnable ) ignore = true; if ( test.IsSuite ) { FireSuiteStarting( test.TestName ); TestSuiteResult result = new TestSuiteResult( test, test.TestName.Name ); foreach( TestNode childTest in test.Tests ) result.AddResult( SimulateTest( childTest, ignore ) ); FireSuiteFinished( result ); return result; } else { FireTestStarting( test.TestName ); TestCaseResult result = new TestCaseResult( test ); result.RunState = ignore ? RunState.Ignored : RunState.Executed; FireTestFinished( result ); return result; } }
public void Setup() { statusBar = new StatusBar(); TestSuiteBuilder builder = new TestSuiteBuilder(); suite = new TestNode( builder.Build( new TestPackage( testsDll ) ) ); mockEvents = new MockTestEventSource( suite ); }
/// <summary> /// Construct from an ITest /// </summary> /// <param name="test">Test from which a TestNode is to be constructed</param> public TestNode ( ITest test ) : base( test ) { if ( test.IsSuite ) { this.tests = new ArrayList(); foreach( ITest child in test.Tests ) { TestNode node = new TestNode( child ); this.Tests.Add( node ); node.parent = this; } } }
public void SetUp() { MethodInfo fakeTestMethod = GetType().GetMethod("FakeTestCase", BindingFlags.Instance | BindingFlags.NonPublic); var nunitTest = new NUnitTestMethod(fakeTestMethod); nunitTest.Categories.Add("cat1"); nunitTest.Properties.Add("Priority", "medium"); var nunitFixture = new TestSuite("FakeNUnitFixture"); nunitFixture.Categories.Add("super"); nunitFixture.Add(nunitTest); Assert.That(nunitTest.Parent, Is.SameAs(nunitFixture)); var fixtureNode = new TestNode(nunitFixture); fakeNUnitTest = (ITest)fixtureNode.Tests[0]; testConverter = new TestConverter(new TestLogger(), ThisAssemblyPath); }
static void ProcessTestNode(TestNode node) { if (node.TestType == "TestFixture") { if (node.Categories.Contains("Logistics")) { var testName = node.TestName; Console.Write(testName.Name + "\r\n"); } }else if (node.TestType == "Namespace") { foreach (TestNode child in node.Tests) { ProcessTestNode(child); } }else { Console.Write(node.TestType); } }
public virtual void Unload() { if (aggregateTest != null) { Log.Info("Unloading " + Path.GetFileName(aggregateTest.TestName.Name)); foreach (TestRunner runner in runners) runner.Unload(); aggregateTest = null; Log.Info("Unload complete"); } }
/// <summary> /// Add nodes to the tree constructed from a test /// </summary> /// <param name="nodes">The TreeNodeCollection to which the new node should be added</param> /// <param name="rootTest">The test for which a node is to be built</param> /// <param name="highlight">If true, highlight the text for this node in the tree</param> /// <returns>A newly constructed TestNode, possibly with descendant nodes</returns> private TestSuiteTreeNode AddTreeNodes( IList nodes, TestNode rootTest, bool highlight ) { TestSuiteTreeNode node = new TestSuiteTreeNode( rootTest ); // if ( highlight ) node.ForeColor = Color.Blue; AddToMap( node ); nodes.Add( node ); if ( rootTest.IsSuite ) { foreach( TestNode test in rootTest.Tests ) AddTreeNodes( node.Nodes, test, highlight ); } return node; }
/// <summary> /// Reload the tree with a changed test hierarchy /// while maintaining as much gui state as possible. /// </summary> /// <param name="test">Test suite to be loaded</param> public void Reload( TestNode test ) { bool reloadOK = false; try { string selectedName = ((TestSuiteTreeNode)SelectedNode).Test.TestName.FullName; UpdateNode((TestSuiteTreeNode)Nodes[0], test, new ArrayList()); TreeNode selectedNode = this.FindNodeByName(selectedName); if (selectedNode != null) { SelectedNode = selectedNode; selectedNode.EnsureVisible(); } reloadOK = true; } catch (TreeStructureChangedException) { } // The tree has changed, probably due to settings // changes, so just load it cleanly. if ( !reloadOK ) Load(test); this.Focus(); }
/// <summary> /// Load the tree with a test hierarchy /// </summary> /// <param name="test">Test to be loaded</param> public void Load( TestNode test ) { using( new CP.Windows.Forms.WaitCursor() ) { Clear(); BeginUpdate(); try { AddTreeNodes( Nodes, test, false ); SetInitialExpansion(); } finally { EndUpdate(); contextNode = null; this.Select(); } if ( Services.UserSettings.GetSetting( "Gui.TestTree.SaveVisualState", true ) && loader != null) RestoreVisualState(); } }
/// <summary> /// A node has been matched with a test, so update it /// and then process child nodes and tests recursively. /// If a child was added or removed, then this node /// will expand itself. /// </summary> /// <param name="node">Node to be updated</param> /// <param name="test">Test to plug into node</param> /// <returns>True if a child node was added or deleted</returns> private bool UpdateNode( TestSuiteTreeNode node, TestNode test, IList deletedNodes ) { if ( node.Test.TestName.FullName != test.TestName.FullName ) throw( new TreeStructureChangedException( string.Format( "Attempting to update {0} with {1}", node.Test.TestName.FullName, test.TestName.FullName ) ) ); treeMap.Remove( node.Test.TestName.UniqueName ); node.Test = test; treeMap.Add( test.TestName.UniqueName, node ); if ( !test.IsSuite ) return false; bool showChildren = UpdateNodes( node.Nodes, test.Tests, deletedNodes ); if ( showChildren ) node.Expand(); return showChildren; }
/// <summary> /// Helper routine that compares a node with a test /// </summary> /// <param name="node">Node to compare</param> /// <param name="test">Test to compare</param> /// <returns>True if the test has the same name</returns> private bool Match( TestSuiteTreeNode node, TestNode test ) { return node.Test.TestName.FullName == test.TestName.FullName; }
public virtual void Unload() { foreach( TestRunner runner in runners ) runner.Unload(); aggregateTest = null; }
public MockTestEventSource( TestNode test ) { this.test = test; //this.testFileName = testFileName; }
/// <summary> /// Reload the tree with a changed test hierarchy /// while maintaining as much gui state as possible. /// </summary> /// <param name="test">Test suite to be loaded</param> public void Reload( TestNode test ) { TestResult result = ((TestSuiteTreeNode)Nodes[0]).Result; VisualState visualState = new VisualState(this); Load(test); visualState.Restore(this); if (result != null && !Services.UserSettings.GetSetting("Options.TestLoader.ClearResultsOnReload", false)) RestoreResults(result); }
/// <summary> /// Reload the tree with a changed test hierarchy /// while maintaining as much gui state as possible. /// </summary> /// <param name="test">Test suite to be loaded</param> public void Reload( TestNode test ) { UpdateNode( (TestSuiteTreeNode) Nodes[0], test ); }
/// <summary> /// Load the tree with a test hierarchy /// </summary> /// <param name="test">Test to be loaded</param> public void Load( TestNode test ) { using( new CP.Windows.Forms.WaitCursor() ) { Clear(); BeginUpdate(); try { AddTreeNodes( Nodes, test, false ); SetInitialExpansion(); } finally { EndUpdate(); contextNode = null; } } }