private static void Summarize(ResultSummary s, XmlNodeList nodes)
 {
     foreach (XmlNode childResult in nodes)
     {
         Summarize(s, childResult);
     }
 }
        private static void Summarize(ResultSummary s, XmlNode node)
        {
            string type = node.GetAttribute("type");
            string status = node.GetAttribute("result");
            string label = node.GetAttribute("label");

            switch (node.Name)
            {
                case "test-case":
                    s.TestCount++;

                    switch (status)
                    {
                        case "Passed":
                            s.PassCount++;
                            break;
                        case "Failed":
                            if (label == null)
                                s.FailureCount++;
                            else if (label == "Invalid")
                                s.InvalidCount++;
                            else
                                s.ErrorCount++;
                            break;
                        case "Inconclusive":
                            s.InconclusiveCount++;
                            break;
                        case "Skipped":
                            if (label == "Ignored")
                                s.IgnoreCount++;
                            else if (label == "Explicit")
                                s.ExplicitCount++;
                            else
                                s.SkipCount++;
                            break;
                        default:
                            s.SkipCount++;
                            break;
                    }
                    break;

                case "test-suite":
                    if (type == "Assembly" && status == "Failed" && label == "Invalid")
                        s.InvalidAssemblies++;
                    if (type == "Assembly" && status == "Failed" && label == "Error")
                    {
                        s.InvalidAssemblies++;
                        s.UnexpectedError = true;
                    }

                    Summarize(s, node.ChildNodes);
                    break;

                case "test-run":
                    Summarize(s, node.ChildNodes);
                    break;
            }
        }
        private static ResultSummary ReadResultSummary(XmlNode result)
        {
            if (result.Name != "test-run")
                throw new InvalidOperationException("Expected <test-run> as top-level element but was <" + result.Name + ">");
            var s = new ResultSummary();
            ResultSummary.InitializeCounters(s);

            Summarize(s, result);
            return s;
        }
Пример #4
0
 public TestEventHandler(HostedOptions options, TextWriter outWriter, Messages.OnMessage[] subscribers)
 {
     this.level                    = 0;
     this.s                        = new ResultSummary();
     this.options                  = options;
     this.outWriter                = outWriter;
     this.currentTestName          = string.Empty;
     this._messageSubscribeAdapter = subscribers != null
         ? new TestMessageSubscriberAdapter(Messages.CombineSubscribers(subscribers))
         : null;
     AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(this.OnUnhandledException);
 }
Пример #5
0
 public void SuiteStarted(TestName testName)
 {
     if (this.level++ != 0)
     {
         return;
     }
     ResultSummary.InitializeCounters(s);
     if (this._messageSubscribeAdapter != null)
     {
         this._messageSubscribeAdapter.SuiteStarted(testName);
     }
 }
        private static ResultSummary ReadResultSummary(XmlNode result)
        {
            if (result.Name != "test-run")
            {
                throw new InvalidOperationException("Expected <test-run> as top-level element but was <" + result.Name + ">");
            }
            var s = new ResultSummary();

            ResultSummary.InitializeCounters(s);

            Summarize(s, result);
            return(s);
        }
 public TestResults(Code code, string message, ResultSummary summary) : this(code, message)
 {
     this.Summary = summary;
 }
 private static void Summarize(ResultSummary s, XmlNodeList nodes)
 {
     foreach (XmlNode childResult in nodes)
         Summarize(s, childResult);
 }
 public TestResults(Code code, string message, ResultSummary summary) : this(code, message)
 {
     this.Summary = summary;
 }
        private static void Summarize(ResultSummary s, XmlNode node)
        {
            string type   = node.GetAttribute("type");
            string status = node.GetAttribute("result");
            string label  = node.GetAttribute("label");

            switch (node.Name)
            {
            case "test-case":
                s.TestCount++;

                switch (status)
                {
                case "Passed":
                    s.PassCount++;
                    break;

                case "Failed":
                    if (label == null)
                    {
                        s.FailureCount++;
                    }
                    else if (label == "Invalid")
                    {
                        s.InvalidCount++;
                    }
                    else
                    {
                        s.ErrorCount++;
                    }
                    break;

                case "Inconclusive":
                    s.InconclusiveCount++;
                    break;

                case "Skipped":
                    if (label == "Ignored")
                    {
                        s.IgnoreCount++;
                    }
                    else if (label == "Explicit")
                    {
                        s.ExplicitCount++;
                    }
                    else
                    {
                        s.SkipCount++;
                    }
                    break;

                default:
                    s.SkipCount++;
                    break;
                }
                break;

            case "test-suite":
                if (type == "Assembly" && status == "Failed" && label == "Invalid")
                {
                    s.InvalidAssemblies++;
                }
                if (type == "Assembly" && status == "Failed" && label == "Error")
                {
                    s.InvalidAssemblies++;
                    s.UnexpectedError = true;
                }

                Summarize(s, node.ChildNodes);
                break;

            case "test-run":
                Summarize(s, node.ChildNodes);
                break;
            }
        }