Exemple #1
0
    public UUnitTestResult RunAll()
    {
        UUnitTestResult res = new UUnitTestResult();

        foreach (Type t in testCases)
        {
            string typeName = t.Name;
            foreach (MethodInfo m in t.GetMethods())
            {
                if (m.Name.StartsWith("Test") && m.GetParameters().Length == 0)
                {
                    ConstructorInfo[] p = t.GetConstructors();

                    for (int i = 0; i < p.Length; i++)
                    {
                        if (p[i].GetParameters().Length == 0)
                        {
                            DateTime startTime1 = DateTime.Now;
                            DateTime stopTime1  = DateTime.Now;

                            UUnitAssertException ae = null;
                            string errMsg           = null;
                            bool   success          = true;
                            try {
                                UUnitTestCase unitTest = (UUnitTestCase)p[i].Invoke(new object[0]);
                                unitTest.Setup();
                                startTime1 = DateTime.Now;
                                m.Invoke(unitTest, new object[0]);
                                stopTime1 = DateTime.Now;
                                unitTest.TearDown();
                            } catch (System.Reflection.TargetInvocationException e) {
                                stopTime1 = DateTime.Now;
                                ae        = e.InnerException as UUnitAssertException;
                                success   = false;
                                if (ae == null)
                                {
                                    errMsg = e.InnerException.ToString();
                                }
                                else
                                {
                                    errMsg = ae.Message;
                                }
                            } catch (System.Exception ex) {
                                stopTime1 = DateTime.Now;
                                success   = false;
                                errMsg    = ex.ToString();
                            }
                            TimeSpan duration1       = stopTime1 - startTime1;
                            double   timeSpendMillis = duration1.TotalMilliseconds;

                            res.AddTestResult(typeName, m.Name, success, ae, timeSpendMillis, errMsg);
                        }
                    }
                }
            }
        }
        return(res);
    }
Exemple #2
0
 public void AddAll(Type testCaseType)
 {
     foreach (MethodInfo method in testCaseType.GetMethods())
     {
         foreach (Attribute attribute in method.GetCustomAttributes(false))
         {
             if (attribute != null)
             {
                 ConstructorInfo constructor = testCaseType.GetConstructors() [0];
                 UUnitTestCase   newTestCase = (UUnitTestCase)constructor.Invoke(null);
                 newTestCase.SetTest(method.Name);
                 Add(newTestCase);
             }
         }
     }
 }
 public void Add(UUnitTestCase testCase)
 {
     tests.Add(testCase);
 }
Exemple #4
0
 public void Add(UUnitTestCase testCase)
 {
     tests.Add(testCase);
 }
	public void Add(UUnitTestCase o){
		Add(o.GetType());
	}
Exemple #6
0
 public void Add(UUnitTestCase o)
 {
     Add(o.GetType());
 }