示例#1
0
 static void Main(string[] args)
 {
     TestSuite suite = new TestSuite();
     suite.add(TestCase.CreateSuite(typeof(TestCaseTest)));
     suite.add(TestCase.CreateSuite(typeof(AssertTest)));
     TestResult result = new TestResult();
     suite.run(result);
     Console.WriteLine(result.summary());
 }
示例#2
0
 public void testSuite()
 {
     TestSuite suite = new TestSuite();
     suite.add(new WasRun("testMethod"));
     suite.add(new WasRun("testBrokenMethod"));
     suite.run(result);
     Assert.AreEqual("2 run, 1 failed", result.summary());
 }
示例#3
0
        public static TestSuite CreateSuite(Type type)
        {
            TestSuite suite = new TestSuite();
            MethodInfo[] methodInfos = type.GetMethods(BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public);

            foreach (MethodInfo methodInfo in methodInfos)
            {
                if (methodInfo.Name != "setUp" && methodInfo.Name != "tearDown")
                {
                    suite.add((TestCase)type.GetConstructor(new Type[] { typeof(string) }).Invoke(new object[] { methodInfo.Name }));
                }
            }

            return suite;
        }