Пример #1
0
        private TestStats GetStatistics(IEnumerable <XElement> elements)
        {
            TestStats stats = new TestStats();

            foreach (XElement element in elements)
            {
                TestStats elementStats = GetStatistics(element);

                switch (elementStats.Outcome)
                {
                case StepStatusEnum.Done:
                    stats.Done += elementStats.Done; break;

                case StepStatusEnum.Pass:
                    stats.Pass += elementStats.Pass; break;

                case StepStatusEnum.Warning:
                    stats.Warning += elementStats.Warning; break;

                case StepStatusEnum.Fail:
                    stats.Fail += elementStats.Fail; break;

                case StepStatusEnum.Error:
                    stats.Error += elementStats.Error; break;

                case StepStatusEnum.Fatal:
                    stats.Fatal += elementStats.Fatal; break;
                }
            }

            stats.Calculate();

            return(stats);
        }
Пример #2
0
        private TestStats GetStatistics(XElement element)
        {
            TestStats stats = new TestStats();

            try { stats.Done = Convert.ToInt32(element.Attribute(Enum.GetName(typeof(StepStatusEnum), StepStatusEnum.Done).ToLower()).Value); }
            catch { stats.Done = 0; }

            try { stats.Pass = Convert.ToInt32(element.Attribute(Enum.GetName(typeof(StepStatusEnum), StepStatusEnum.Pass).ToLower()).Value); }
            catch { stats.Pass = 0; }

            try { stats.Warning = Convert.ToInt32(element.Attribute(Enum.GetName(typeof(StepStatusEnum), StepStatusEnum.Warning).ToLower()).Value); }
            catch { stats.Warning = 0; }

            try { stats.Fail = Convert.ToInt32(element.Attribute(Enum.GetName(typeof(StepStatusEnum), StepStatusEnum.Fail).ToLower()).Value); }
            catch { stats.Fail = 0; }

            try { stats.Error = Convert.ToInt32(element.Attribute(Enum.GetName(typeof(StepStatusEnum), StepStatusEnum.Error).ToLower()).Value); }
            catch { stats.Error = 0; }

            try { stats.Fatal = Convert.ToInt32(element.Attribute(Enum.GetName(typeof(StepStatusEnum), StepStatusEnum.Fatal).ToLower()).Value); }
            catch { stats.Fatal = 0; }

            stats.Calculate();

            return(stats);
        }
Пример #3
0
        //public void OpenSection(string sectionName)
        //{
        //    throw new NotImplementedException();
        //}

        //public void CloseSection()
        //{
        //    throw new NotImplementedException();
        //}
        #endregion IReporter interface implementation

        #region Private Methods
        private TestRunSummary SummarizeRun()
        {
            TestRunSummary runSummary;
            string         name;
            TestStats      stats = new TestStats();
            long           startTime, endTime;

            name = this.SuiteName;

            stats = GetStatistics(_xDoc.Document.Root.XPathSelectElements($"./{ReportElements.TestTag}/{ReportElements.StatusElement}"));

            try { startTime = (long)Convert.ToDecimal(_xDoc.Document.Root.Element(ReportElements.TestTag).Attribute(ReportElements.StartTimeAttribute).Value); }
            catch { startTime = 0; }

            try { endTime = (long)Convert.ToDecimal(_xDoc.Document.Root.Elements(ReportElements.TestTag).Last().Attribute(ReportElements.EndTimeAttribute).Value); }
            catch { endTime = 0; }

            runSummary = new TestRunSummary()
            {
                Name            = name,
                StartTime       = startTime,
                EndTime         = endTime,
                NumberOfChilds  = stats.Total,
                NumberOfPass    = stats.Pass,
                NumberOfWarning = stats.Warning,
                NumberOfFail    = stats.Fail,
                NumberOfFatal   = stats.Error + stats.Fatal,
            };

            return(runSummary);
        }
Пример #4
0
        public TestStats(TestStats test)
        {
            Reset();

            this.Total = test.Total;

            this.Fatal = test.Fatal;
            if (this.Fatal > 0)
            {
                this.Outcome = StepStatusEnum.Fatal;
            }

            this.Error = test.Error;
            if (this.Error > 0)
            {
                this.Outcome = StepStatusEnum.Error;
            }

            this.Fail = test.Fail;
            if (this.Fail > 0)
            {
                this.Outcome = StepStatusEnum.Fail;
            }

            this.Warning = test.Warning;
            if (this.Warning > 0)
            {
                this.Outcome = StepStatusEnum.Warning;
            }

            this.Pass = test.Pass;
            if (this.Pass > 0)
            {
                this.Outcome = StepStatusEnum.Pass;
            }

            this.Done = test.Done;
        }
Пример #5
0
 public static string Serialize(TestStats testStats, SerializeReportAsEnum serializeAs)
 {
     return(testStats.ToString());
 }