Beispiel #1
0
        /// --------------------------------------------------------------------
        /// <summary>Add the issue to the FailedFilter xml file.  This is a file 
        /// that has the appended new errors.  After viewing this, replace/add 
        /// the nodes to the actual filter file.</summary>
        /// --------------------------------------------------------------------
        internal static void AddIssue(Exception exception, AutomationElement element, int testStep)
        {
            try
            {
                string filterFile = @"FailedFilter.xml";

                if (null == _newFilterDoc)
                {
                    _newFilterDoc = new XmlDocument();

                    if (System.IO.File.Exists(filterFile))
                    {
                        _newFilterDoc.Load(filterFile);
                    }
                }

                /*
                 <Test Method="Microsoft.Test.UIAutomation.Tests.Patterns.AutomationElementTests.TestSetFocus1a" TestName="SetFocus.1" Pri="Pri1">
                    <FailedStep Step="9">
                        <Issue Verification="Check_IsCheckBox">
                            <Repro OS="6.1" ClientSideProvider="T" PS
                 */

                TestCaseAttribute attribute;
                StringBuilder sbPath;
                StringBuilder verificationMethod;

                string methodName = GetTestMethodThatThrowException(exception, out attribute);

                GetElementsPathAndPossibleVerificationMethod(element, out sbPath, out verificationMethod);

                TestNode tn = new TestNode(_newFilterDoc, testStep, exception.Message, methodName, TestRuns.IsClientSideProviderLoaded, attribute, verificationMethod.ToString(), sbPath.ToString());

                XmlElement nodeSteps;
                tn.GetStepNode(out nodeSteps);

                XmlElement nodeRepro;
                tn.GetReproNode(out nodeRepro);

                TestObject.Comment("_________");
                TestObject.Comment("Test Method        = {0}", methodName);
                TestObject.Comment("FailedStep Step    = {0}", testStep);
                TestObject.Comment("Issue Verification = {0}", verificationMethod);
                TestObject.Comment("Path               = {0}", sbPath);
                TestObject.Comment("XML                = {0}", nodeRepro.ParentNode.OuterXml);
                TestObject.Comment("_________");


                _newFilterDoc.Save(filterFile);
                TestObject.Comment("{0} is saved.", filterFile);

            }
            catch (Exception)
            {
                TestObject.Comment(exception.Message);
                // Eat the exception and go on
                //System.Windows.Forms.MessageBox.Show(string.Format("Could not update the bug file({0});", e.Message));
            }
        }
Beispiel #2
0
        /// --------------------------------------------------------------------
        /// <summary>This will match up the test method BugAttribute, then 
        /// BugLibrary BugAttributes, and the known step that is occuring in 
        /// real time. If these threse items do not match, there will not be a 
        /// matching BugAttribute.</summary>
        /// <returns>If any of the bugs associated with the test case repro</returns>
        /// --------------------------------------------------------------------
        public static bool IsIssueKnown(Exception exception, AutomationElement element, int step, out string knownIssue)
        {
            knownIssue = exception.Message;
            string fullQualified;
            if (Path.IsPathRooted(TestRuns.BugFilterFile))
            {
                fullQualified = TestRuns.BugFilterFile;
            }
            else
            {
                fullQualified = Path.Combine(Directory.GetCurrentDirectory(), TestRuns.BugFilterFile);
            }

            // Could load this once, but do it everytime.  This helps when reporting errors, you can update the xml on the fly and
            // re-run your tests without restarting UIV.  Hardcode the name for now, come back in and add it dynamically if we need it.
            if (TestRuns.BugFilterFile != string.Empty && TestRuns.FilterOutBugs)
            {
                if (System.IO.File.Exists(fullQualified))
                {
                    TestCaseAttribute attribute;
                    string methodName = GetTestMethodThatThrowException(exception, out attribute);
                    _filterDoc = new XmlDocument();
                    _filterDoc.Load(fullQualified);

                    TestObject.Comment(string.Format(string.Format("Verifying if this is a know issue by verify results in {0}.", fullQualified)));

                    TestNode tn = new TestNode(_filterDoc, step, methodName, TestRuns.IsClientSideProviderLoaded);

                    foreach (XmlNode node in _filterDoc.SelectNodes(tn.ReproPathString))
                    {
                        XmlAttribute attrVerificationMethod = node.ParentNode.Attributes[TestNode.str_VerificationMethod];
                        if (null != attrVerificationMethod)
                        {
                            string verificationMethod = attrVerificationMethod.Value;
                            if (!string.IsNullOrEmpty(verificationMethod))
                            {
                                MethodInfo methodInfo = typeof(BugLibrary).GetMethod(verificationMethod);

                                if (methodInfo == null)
                                {
                                    throw new ArgumentException("There is no verification called '{0}' in BugsLibrary.cs", verificationMethod);
                                }

                                bool isScenario = (bool)methodInfo.Invoke(null, new object[] { element });
                                if (isScenario)
                                {
                                    return true;
                                }
                            }
                        }
                    }
                    TestObject.Comment("Could not find issue with [{0}]", tn.ReproPathString);
                }
            }
            
            return false;
        }