IsTestMethod() public static method

public static IsTestMethod ( MethodInfo method ) : bool
method System.Reflection.MethodInfo
return bool
Beispiel #1
0
        public TestSuite(Type type)
        {
            TestObject = Reflect.Construct(type, null);

            this.name     = type.Name;
            this.fullName = type.FullName;

            object[] attrs = type.GetCustomAttributes(typeof(PropertyAttribute), true);
            foreach (PropertyAttribute attr in attrs)
            {
                foreach (DictionaryEntry entry in attr.Properties)
                {
                    this.Properties[entry.Key] = entry.Value;
                }
            }

            IgnoreAttribute ignore = (IgnoreAttribute)Reflect.GetAttribute(type, typeof(IgnoreAttribute));

            if (ignore != null)
            {
                this.runState     = RunState.Ignored;
                this.ignoreReason = ignore.Reason;
            }

            if (!InvalidTestSuite(type))
            {
                foreach (MethodInfo method in type.GetMethods())
                {
                    if (TestCase.IsTestMethod(method))
                    {
                        this.AddTest(new TestCase(method, TestObject));
                    }
                    else if (IsTestFixtureSetup(method))
                    {
                        TestFixtureSetUpMethod = method;
                    }
                    else if (IsTestFixtureTearDownAttribute(method))
                    {
                        TestFixtureTearDownMethod = method;
                    }
                }
            }
        }
Beispiel #2
0
        public TestSuite(Type type)
        {
            this.name     = type.Name;
            this.fullName = type.FullName;

            object[] attrs = type.GetCustomAttributes(typeof(PropertyAttribute), true);
            foreach (PropertyAttribute attr in attrs)
            {
                foreach (var entry in attr.Properties)
                {
                    this.Properties[entry.Key] = entry.Value;
                }
            }

            IgnoreAttribute ignore = (IgnoreAttribute)Reflect.GetAttribute(type, typeof(IgnoreAttribute));

            if (ignore != null)
            {
                this.runState     = RunState.Ignored;
                this.ignoreReason = ignore.Reason;
            }

            if (!InvalidTestSuite(type))
            {
                foreach (MethodInfo method in type.GetMethods())
                {
                    if (TestCase.IsTestMethod(method))
                    {
                        this.AddTest(new TestCase(method));
                    }
                    //{
                    //    ITest test = TestCase.HasValidSignature(method)
                    //        ? (ITest)new TestCase(method)
                    //        : (ITest)new InvalidTestCase(method.Name,
                    //            "Test methods must have signature void MethodName()");

                    //    this.AddTest(test);
                    //}
                }
            }
        }