public Test Decorate(Test test, MemberInfo member)
        {
            NUnitTestMethod testMethod = test as NUnitTestMethod;
            
            if (testMethod != null && testMethod.RunState == RunState.Runnable)
            {
                List<Attribute> ignoreAttributes = new List<Attribute>();
                Attribute[] ignoreAttr = Reflect.GetAttributes(member, IgnoreBrowserAttributeTypeFullName, true);
                if (ignoreAttr != null)
                {
                    ignoreAttributes.AddRange(ignoreAttr);
                }

                Attribute[] ignoreClassAttributes = Reflect.GetAttributes(member.DeclaringType, IgnoreBrowserAttributeTypeFullName, true);
                if (ignoreClassAttributes != null)
                {
                    ignoreAttributes.AddRange(ignoreClassAttributes);
                }

                foreach (Attribute attr in ignoreAttributes)
                {
                    IgnoreBrowserAttribute browserToIgnoreAttr = attr as IgnoreBrowserAttribute;
                    if (browserToIgnoreAttr != null && IgnoreTestForBrowser(browserToIgnoreAttr.Value))
                    {
                        string ignoreReason = "Ignoring browser " + EnvironmentManager.Instance.Browser.ToString() + ".";
                        if (!string.IsNullOrEmpty(browserToIgnoreAttr.Reason))
                        {
                            ignoreReason = ignoreReason + " " + browserToIgnoreAttr.Reason;
                        }

                        test.RunState = RunState.Ignored;
                        test.IgnoreReason = ignoreReason;
                    }
                }
                

                if (test.RunState == RunState.Runnable)
                {
                    NeedsFreshDriverAttribute needsDriverAttr = Reflect.GetAttribute(member, NeedsFreshDriverAttributeTypeFullName, false) as NeedsFreshDriverAttribute;
                    if (needsDriverAttr != null)
                    {
                        test = new WebDriverTestMethod(testMethod, needsDriverAttr.BeforeTest, needsDriverAttr.AfterTest);
                    }
                }
            }

            return test;
        }
示例#2
0
        public Test Decorate(Test test, MemberInfo member)
        {
            NUnitTestMethod testMethod = test as NUnitTestMethod;

            if (testMethod != null && testMethod.RunState == RunState.Runnable)
            {
                List <Attribute> ignoreAttributes = new List <Attribute>();
                Attribute[]      ignoreAttr       = Reflect.GetAttributes(member, IgnoreBrowserAttributeTypeFullName, true);
                if (ignoreAttr != null)
                {
                    ignoreAttributes.AddRange(ignoreAttr);
                }

                Attribute[] ignoreClassAttributes = Reflect.GetAttributes(member.DeclaringType, IgnoreBrowserAttributeTypeFullName, true);
                if (ignoreClassAttributes != null)
                {
                    ignoreAttributes.AddRange(ignoreClassAttributes);
                }

                foreach (Attribute attr in ignoreAttributes)
                {
                    IgnoreBrowserAttribute browserToIgnoreAttr = attr as IgnoreBrowserAttribute;
                    if (browserToIgnoreAttr != null && IgnoreTestForBrowser(browserToIgnoreAttr.Value))
                    {
                        string ignoreReason = "Ignoring browser " + EnvironmentManager.Instance.Browser.ToString() + ".";
                        if (!string.IsNullOrEmpty(browserToIgnoreAttr.Reason))
                        {
                            ignoreReason = ignoreReason + " " + browserToIgnoreAttr.Reason;
                        }

                        test.RunState     = RunState.Ignored;
                        test.IgnoreReason = ignoreReason;
                    }
                }


                if (test.RunState == RunState.Runnable)
                {
                    NeedsFreshDriverAttribute needsDriverAttr = Reflect.GetAttribute(member, NeedsFreshDriverAttributeTypeFullName, false) as NeedsFreshDriverAttribute;
                    if (needsDriverAttr != null)
                    {
                        test = new WebDriverTestMethod(testMethod, needsDriverAttr.BeforeTest, needsDriverAttr.AfterTest);
                    }
                }
            }

            return(test);
        }