Exemplo n.º 1
0
 public void Update(TestNode test)
 {
     Update(test.GetStat(Runtime));
 }
Exemplo n.º 2
0
        static void LoadTestSuite(IType type)
        {
            foreach (var test in type.GetUnitTests())
            {
                XmlElement[] elems = null;
                if (Global.NUnitReport != null)
                {
                    elems = FindNUnitElems(test);
                    if (elems == null)
                    {
                        continue;
                    }
                    if (elems.Length == 0)
                    {
                        continue;
                    }
                    if (!elems.Any(IsExecuted))
                    {
                        continue;
                    }
                }

                string fullname = GetTestCaseFullName(test);
                fullname = Utils.RemovePrefix(fullname, "mono.");

                int    dot   = fullname.LastIndexOf('.');
                string klass = fullname.Substring(0, dot);

                var parent = Global.TestRoot;
                var tc     = new TestNode
                {
                    FullName = fullname,
                    Name     = fullname.Substring(dot + 1),
                    Method   = test
                };

                CacheCalls(tc);

                if (elems != null && elems.Length > 0)
                {
                    foreach (var elem in elems)
                    {
                        if (!IsExecuted(elem))
                        {
                            continue;
                        }
                        var stat = tc.GetStat(GetRuntime(elem));
                        if (stat != null)
                        {
                            stat.Success = IsSuccess(elem);
                            stat.Time    = GetTime(elem);
                        }
                    }
                }
                else
                {
                    tc.Success = true;
                }

                dot = klass.LastIndexOf('.');
                var path = new[] { klass.Substring(0, dot), klass.Substring(dot + 1) };
                for (int i = 0; i < path.Length; ++i)
                {
                    string tsname = path[i];
                    var    ts     = (TestNode)parent[tsname];
                    if (ts == null)
                    {
                        ts = new TestNode
                        {
                            Name = tsname
                        };
                        ts.FullName = i == 1 ? klass : ts.Name;
                        parent.Add(ts);
                        parent = ts;
                    }
                    else
                    {
                        parent = ts;
                    }

                    parent.UpdateStats(tc);
                }
                parent.Add(tc);
            }
        }