Ejemplo n.º 1
0
        public virtual void RunTestSuite()
        {
            TestSuite   s      = suite();
            IEnumerator e      = s.enumerate();
            ArrayList   errors = new ArrayList();

            int index = 0;

            while (e != null && e.MoveNext())
            {
                OgnlTestCase test = (OgnlTestCase)e.Current;

                test.setUp();
                try
                {
                    Console.Write("Run TestCase " + index + " [  " + test.name + "  ] ...");
                    test.runTest();
                    Console.WriteLine("SUCCESS.");
                }
                catch (Exception ex)
                {
                    errors.Add(new Error(test, ex, index));
                    // throw ex ;
                    Console.WriteLine("Falied!");
                    Console.WriteLine(ex);
                }
                index++;
            }
            if (errors.Count > 0)
            {
                // report error
                StringBuilder sb = new StringBuilder(1024 * 4);
                sb.Append("Failed with following TestCase:");
                for (int i = 0; i < errors.Count; i++)
                {
                    sb.Append('\n');
                    Error error = (Error)errors [i];
                    sb.Append(error.index);
                    sb.Append(" [  ");
                    sb.Append(error.test.expression);
                    sb.Append("  ]");
                    sb.Append(" With error: ");
                    sb.Append(error.ex);
                }



                Assert.Fail();
            }
        }
Ejemplo n.º 2
0
 public Error(OgnlTestCase test, Exception ex, int index)
 {
     this.test  = test;
     this.ex    = ex;
     this.index = index;
 }