class encapsulating automation test
Exemplo n.º 1
0
        /// <summary>
        /// initializes new instance with the testPriority and testType
        /// </summary>
        public AutomationTest(AutomationTest originalTest, TestPriorities testPriority, TestTypes testType)
        {
            this.TestCaseAttribute = originalTest.TestCaseAttribute;
            this.Method = originalTest.Method;

            this._testPriority = testPriority;
            this._testType = testType;
        }
Exemplo n.º 2
0
        /// <summary>
        /// This method add test to list of all test.
        /// </summary>
        internal void AddTest(AutomationTest test, AutomationElement automationElement)
        {
            //creare ListView item for the test
            ListViewItem item = new ListViewItem();
            item.Text = GetTestName(test);
            item.SubItems.Add(GetAutomationElementName(automationElement));
            item.SubItems.Add(GetTestResultName(TestResults.ReadyToRun));
            item.ImageIndex = GetImageIndexForStatus(TestResults.ReadyToRun);
            
            this._testListView.Items.Add(item);

            //ad it to the collection of all tests
            this._testList.Add(new object[] { test, automationElement, item });
        }
Exemplo n.º 3
0
 public override bool Fit(AutomationTest test)
 {
     return true;
 }
Exemplo n.º 4
0
 /// <summary>
 /// Method which return TRUE if test fits this filter. Otherwise FALSE.
 /// </summary>
 public abstract bool Fit(AutomationTest test);
Exemplo n.º 5
0
 public override bool Fit(AutomationTest test)
 {
     return test.IsPatternTestForSupportedPatterns(this._patternName);
 }
Exemplo n.º 6
0
 public override bool Fit(AutomationTest test)
 {
     return test.IsControlTestForControlType(this._controlTypeName);
 }
Exemplo n.º 7
0
 public override bool Fit(AutomationTest test)
 {
     return (test.Type & this._testType) == this._testType;
 }
Exemplo n.º 8
0
 /// <summary>
 /// returns name for the test
 /// </summary>
 private string GetTestName(AutomationTest test)
 {
     return(test.Name);
 }
Exemplo n.º 9
0
 /// <summary>
 /// returns test suite for the test
 /// </summary>
 private string GetTestSuite(AutomationTest test)
 {
     return test.Method.ReflectedType.FullName;
 }
Exemplo n.º 10
0
 /// <summary>
 /// returns name for the test
 /// </summary>
 private string GetTestName(AutomationTest test)
 {
     return test.Name;
 }
Exemplo n.º 11
0
        /// <summary>
        /// this method performs automation test on automation element.
        /// </summary>
        public TestResults PerformTest(AutomationTest test, AutomationElement element)
        {
            try
            {
                bool result = false;
                switch (test.Type)
                {
                    case TestTypes.AutomationElementTest:
                        {
                            if(!this._testChildren)
                                result = TestRuns.RunAutomationElementTest(element, this._testEvents, GetTestName(test), false, null, true, GetFakeApplicationCommands());
                            else
                                result = TestRuns.RunAutomationElementTests(element, this._testEvents, test.TestCaseAttribute.Priority, test.TestCaseAttribute.TestCaseType, this._testChildren, true, GetFakeApplicationCommands());
                            break;
                        }
                    case TestTypes.ControlTest:
                        {
                            if (!this._testChildren)
                                result = TestRuns.RunControlTest(element, this._testEvents, GetTestSuite(test), GetTestName(test), null, GetFakeApplicationCommands());
                            else
                                result = TestRuns.RunControlTests(element, this._testEvents, this._testChildren, test.TestCaseAttribute.Priority, test.TestCaseAttribute.TestCaseType, GetFakeApplicationCommands());
                            break;
                        }
                    case TestTypes.PatternTest:
                        {
                            if (!this._testChildren)
                                result = TestRuns.RunPatternTest(element, this._testEvents, false, GetTestSuite(test), GetTestName(test), null, GetFakeApplicationCommands());
                            else
                                result = TestRuns.RunPatternTests(element, this._testEvents, this._testChildren, GetTestSuite(test), test.TestCaseAttribute.TestCaseType, GetFakeApplicationCommands());
                            break;
                        }
                    //case TestTypes.ScenarioTest:
                    //    {
                    //        if (!this._testChildren)
                    //            result = TestRuns.RunScenarioTest(GetTestSuite(test), GetTestName(test), null, this._testEvents, GetFakeApplicationCommands());

                    //        break;
                    //    }
                    default:
                        throw new ArgumentException("not supported test type! test.Type = " + test.Type.ToString() );
                }
                return (result ? TestResults.Succeed : TestResults.Failed);
            }
            catch (Exception ex)
            {
                ApplicationLogger.LogException(ex);
                return TestResults.UnexpectedError; 
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// create subtree for parentNode according to the testPriority, testType and testFilter
        /// </summary>
        private void CreateTestPrioritySubtree(TestPriorities testPriority, TestTypes testType, TreeNode parentNode, AutomationTestsFilter testFilter)
        {
            //create node for the priority
            TreeNode priorityNode = new TreeNode(GetPriorityName(testPriority));
            parentNode.Nodes.Add(priorityNode);
            TreeNode currentRootNode = priorityNode;

            //create filter for the priority
            AndFilter priorityFilter = new AndFilter(new TestFilterPriority(testPriority), testFilter);

            //for all filtered available automation tests lets create tree node
            foreach (AutomationTest test in AutomationTestCollection.Filter(priorityFilter))
            {
                //lets make copy ot the test with only TestType and TestPriority belonging to this
                //branch

                AutomationTest testClone = new AutomationTest(test, testPriority, testType);

                TreeNode testNode = new TreeNode(testClone.Name);
                testNode.Tag = testClone;

                currentRootNode.Nodes.Add(testNode);
            }

            //if no child currentTestTypeRootNode was added then remove priority currentTestTypeRootNode
            if (currentRootNode.Nodes.Count == 0)
                currentRootNode.Remove();
        }
Exemplo n.º 13
0
 /// <summary>
 /// returns test suite for the test
 /// </summary>
 private string GetTestSuite(AutomationTest test)
 {
     return(test.Method.ReflectedType.FullName);
 }
Exemplo n.º 14
0
 public override bool Fit(AutomationTest test)
 {
     return _a.Fit(test) && _b.Fit(test);
 }
Exemplo n.º 15
0
 private string GetTestName(AutomationTest test)
 {
     return test.Method.ReflectedType.Name + "." + test.Name;
 }
Exemplo n.º 16
0
 public override bool Fit(AutomationTest test)
 {
     return (test.Priority & this._testPriority) == this._testPriority;
 }
Exemplo n.º 17
0
        /// <summary>
        /// this method performs automation test on automation element.
        /// </summary>
        public TestResults PerformTest(AutomationTest test, AutomationElement element)
        {
            try
            {
                bool result = false;
                switch (test.Type)
                {
                case TestTypes.AutomationElementTest:
                {
                    if (!this._testChildren)
                    {
                        result = TestRuns.RunAutomationElementTest(element, this._testEvents, GetTestName(test), false, null, true, GetFakeApplicationCommands());
                    }
                    else
                    {
                        result = TestRuns.RunAutomationElementTests(element, this._testEvents, test.TestCaseAttribute.Priority, test.TestCaseAttribute.TestCaseType, this._testChildren, true, GetFakeApplicationCommands());
                    }
                    break;
                }

                case TestTypes.ControlTest:
                {
                    if (!this._testChildren)
                    {
                        result = TestRuns.RunControlTest(element, this._testEvents, GetTestSuite(test), GetTestName(test), null, GetFakeApplicationCommands());
                    }
                    else
                    {
                        result = TestRuns.RunControlTests(element, this._testEvents, this._testChildren, test.TestCaseAttribute.Priority, test.TestCaseAttribute.TestCaseType, GetFakeApplicationCommands());
                    }
                    break;
                }

                case TestTypes.PatternTest:
                {
                    if (!this._testChildren)
                    {
                        result = TestRuns.RunPatternTest(element, this._testEvents, false, GetTestSuite(test), GetTestName(test), null, GetFakeApplicationCommands());
                    }
                    else
                    {
                        result = TestRuns.RunPatternTests(element, this._testEvents, this._testChildren, GetTestSuite(test), test.TestCaseAttribute.TestCaseType, GetFakeApplicationCommands());
                    }
                    break;
                }
                //case TestTypes.ScenarioTest:
                //    {
                //        if (!this._testChildren)
                //            result = TestRuns.RunScenarioTest(GetTestSuite(test), GetTestName(test), null, this._testEvents, GetFakeApplicationCommands());

                //        break;
                //    }
                default:
                    throw new ArgumentException("not supported test type! test.Type = " + test.Type.ToString());
                }
                return(result ? TestResults.Succeed : TestResults.Failed);
            }
            catch (Exception ex)
            {
                ApplicationLogger.LogException(ex);
                return(TestResults.UnexpectedError);
            }
        }