Пример #1
0
        /// <summary>
        /// Return the header for the test summary. The header is the first block of text and will be
        /// followed by the summary of each individual role in the test
        /// </summary>
        /// <returns></returns>
        protected virtual string GetTestSummaryHeader()
        {
            int AbnormalExits = 0;
            int FatalErrors   = 0;
            int Ensures       = 0;
            int Errors        = 0;
            int Warnings      = 0;

            // create a quicck summary of total failures, ensures, errors, etc
            foreach (var Artifact in SessionArtifacts)
            {
                string Summary;
                int    ExitCode = GetRoleSummary(Artifact, out Summary);

                if (ExitCode != 0 && Artifact.AppInstance.WasKilled == false)
                {
                    AbnormalExits++;
                }

                FatalErrors += Artifact.LogSummary.FatalError != null ? 1 : 0;
                Ensures     += Artifact.LogSummary.Ensures.Count();
                Errors      += Artifact.LogSummary.Errors.Count();
                Warnings    += Artifact.LogSummary.Warnings.Count();
            }

            MarkdownBuilder MB = new MarkdownBuilder();

            string WarningStatement = HasWarnings ? " With Warnings" : "";

            var FailureArtifacts = GetArtifactsWithFailures();

            // Create a summary
            MB.H2(string.Format("{0} {1}{2}", Name, GetTestResult(), WarningStatement));

            if (GetTestResult() != TestResult.Passed)
            {
                if (FailureArtifacts.Count() > 0)
                {
                    foreach (var FailedArtifact in FailureArtifacts)
                    {
                        string FirstProcessCause = "";
                        int    FirstExitCode     = GetExitCodeAndReason(FailedArtifact, out FirstProcessCause);
                        MB.H3(string.Format("{0}: {1}", FailedArtifact.SessionRole.RoleType, FirstProcessCause));

                        if (FailedArtifact.LogSummary.FatalError != null)
                        {
                            MB.H4(FailedArtifact.LogSummary.FatalError.Message);
                        }
                    }

                    MB.Paragraph("See below for logs and any callstacks");
                }
            }
            MB.Paragraph(string.Format("Context: {0}", Context.ToString()));
            MB.Paragraph(string.Format("FatalErrors: {0}, Ensures: {1}, Errors: {2}, Warnings: {3}", FatalErrors, Ensures, Errors, Warnings));
            MB.Paragraph(string.Format("Result: {0}, ResultHash: {1}", GetTestResult(), GetTestResultHash()));
            //MB.Paragraph(string.Format("Artifacts: {0}", CachedArtifactPath));

            return(MB.ToString());
        }
        /// <summary>
        /// Reports the summary of this pass, including a sumamry for each test
        /// </summary>
        /// <param name="CurrentPass"></param>
        /// <param name="NumPasses"></param>
        /// <param name="Duration"></param>
        /// <param name="AllInfo"></param>
        /// <returns></returns>
        void ReportMasterSummary(int CurrentPass, int NumPasses, TimeSpan Duration, IEnumerable <TestExecutionInfo> AllInfo)
        {
            MarkdownBuilder MB = new MarkdownBuilder();

            int TestCount    = AllInfo.Count();
            int FailedCount  = AllInfo.Where(T => T.FinalResult != TestResult.Passed).Count();
            int WarningCount = AllInfo.Where(T => T.TestNode.GetWarnings().Any()).Count();

            var SortedInfo = AllInfo;

            // sort our tests by failed/warning/ok
            if (FailedCount > 0 || WarningCount > 0)
            {
                SortedInfo = AllInfo.OrderByDescending(T =>
                {
                    if (T.FinalResult != TestResult.Passed)
                    {
                        return(10);
                    }

                    if (T.TestNode.GetWarnings().Any())
                    {
                        return(5);
                    }

                    return(0);
                });
            }

            Log.Info("Completed test pass {0} of {1}.", CurrentPass, NumPasses);

            MB.H2(string.Format("{0} of {1} Tests Passed in {2:mm\\:ss}. ({3} Failed, {4} Passed with Warnings)",
                                TestCount - FailedCount, TestCount, Duration, FailedCount, WarningCount));

            // write out a list of tests and results
            List <string> TestResults = new List <string>();

            foreach (TestExecutionInfo Info in SortedInfo)
            {
                string WarningString = Info.TestNode.GetWarnings().Any() ? " With Warnings" : "";
                TestResults.Add(string.Format("\t{0} result={1}{2}", Info, Info.FinalResult, WarningString));
            }

            MB.UnorderedList(TestResults);

            // write the markdown out with each line indented
            MB.ToString().Split('\n').ToList().ForEach(L => Log.Info("  " + L));

            if (Options.DeferReports)
            {
                // write each tests full summary
                foreach (TestExecutionInfo Info in SortedInfo)
                {
                    ReportTestSummary(Info);
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Returns a summary of this test
        /// </summary>
        /// <returns></returns>
        public override string GetTestSummary()
        {
            int AbnormalExits = 0;
            int FatalErrors   = 0;
            int Ensures       = 0;
            int Errors        = 0;
            int Warnings      = 0;

            StringBuilder SB = new StringBuilder();

            // Sort our artifacts so any missing processes are first
            var ProblemArtifacts = GetArtifactsWithFailures();

            var AllArtifacts = ProblemArtifacts.Union(SessionArtifacts);

            // create a quicck summary of total failures, ensures, errors, etc
            foreach (var Artifact in AllArtifacts)
            {
                string Summary  = "NoSummary";
                int    ExitCode = GetRoleSummary(Artifact, out Summary);

                if (ExitCode != 0 && Artifact.AppInstance.WasKilled == false)
                {
                    AbnormalExits++;
                }

                if (SB.Length > 0)
                {
                    SB.AppendLine();
                }
                SB.Append(Summary);

                FatalErrors += Artifact.LogSummary.FatalError != null ? 1 : 0;
                Ensures     += Artifact.LogSummary.Ensures.Count();
                Errors      += Artifact.LogSummary.Errors.Count();
                Warnings    += Artifact.LogSummary.Warnings.Count();
            }

            MarkdownBuilder MB = new MarkdownBuilder();

            // Create a summary
            MB.H2(string.Format("{0} {1}", Name, GetTestResult()));

            if (GetTestResult() != TestResult.Passed)
            {
                if (ProblemArtifacts.Count() > 0)
                {
                    foreach (var FailedArtifact in ProblemArtifacts)
                    {
                        string FirstProcessCause = "";
                        int    FirstExitCode     = GetExitCodeAndReason(FailedArtifact, out FirstProcessCause);
                        MB.H3(string.Format("{0}: {1}", FailedArtifact.SessionRole.RoleType, FirstProcessCause));

                        if (FailedArtifact.LogSummary.FatalError != null)
                        {
                            MB.H4(FailedArtifact.LogSummary.FatalError.Message);
                        }
                    }

                    MB.Paragraph("See below for callstack and logs");
                }
            }
            MB.Paragraph(string.Format("Context: {0}", Context.ToString()));
            MB.Paragraph(string.Format("FatalErrors: {0}, Ensures: {1}, Errors: {2}, Warnings: {3}", FatalErrors, Ensures, Errors, Warnings));
            //MB.Paragraph(string.Format("Artifacts: {0}", CachedArtifactPath));
            MB.Append("--------");
            MB.Append(SB.ToString());

            //SB.Clear();
            //SB.AppendLine("begin: stack for UAT");
            //SB.Append(MB.ToString());
            //SB.Append("end: stack for UAT");
            return(MB.ToString());
        }
Пример #4
0
        /// <summary>
        /// Returns a summary of this test
        /// </summary>
        /// <returns></returns>
        public override string GetTestSummary()
        {
            int AbnormalExits = 0;
            int FatalErrors   = 0;
            int Ensures       = 0;
            int Errors        = 0;
            int Warnings      = 0;

            // Handle case where there aren't any session artifacts, for example with device starvation
            if (SessionArtifacts == null)
            {
                return("NoSummary");
            }

            StringBuilder SB = new StringBuilder();

            // Get any artifacts with failures
            var FailureArtifacts = GetArtifactsWithFailures();

            // Any with warnings (ensures)
            var WarningArtifacts = SessionArtifacts.Where(A => A.LogSummary.Ensures.Count() > 0);

            // combine artifacts into order as Failures, Warnings, Other
            var AllArtifacts = FailureArtifacts.Union(WarningArtifacts);

            AllArtifacts = AllArtifacts.Union(SessionArtifacts);

            // create a quicck summary of total failures, ensures, errors, etc
            foreach (var Artifact in AllArtifacts)
            {
                string Summary  = "NoSummary";
                int    ExitCode = GetRoleSummary(Artifact, out Summary);

                if (ExitCode != 0 && Artifact.AppInstance.WasKilled == false)
                {
                    AbnormalExits++;
                }

                if (SB.Length > 0)
                {
                    SB.AppendLine();
                }
                SB.Append(Summary);

                FatalErrors += Artifact.LogSummary.FatalError != null ? 1 : 0;
                Ensures     += Artifact.LogSummary.Ensures.Count();
                Errors      += Artifact.LogSummary.Errors.Count();
                Warnings    += Artifact.LogSummary.Warnings.Count();
            }

            MarkdownBuilder MB = new MarkdownBuilder();

            string WarningStatement = HasWarnings ? " With Warnings" : "";

            // Create a summary
            MB.H2(string.Format("{0} {1}{2}", Name, GetTestResult(), WarningStatement));

            if (GetTestResult() != TestResult.Passed)
            {
                if (FailureArtifacts.Count() > 0)
                {
                    foreach (var FailedArtifact in FailureArtifacts)
                    {
                        string FirstProcessCause = "";
                        int    FirstExitCode     = GetExitCodeAndReason(FailedArtifact, out FirstProcessCause);
                        MB.H3(string.Format("{0}: {1}", FailedArtifact.SessionRole.RoleType, FirstProcessCause));

                        if (FailedArtifact.LogSummary.FatalError != null)
                        {
                            MB.H4(FailedArtifact.LogSummary.FatalError.Message);
                        }
                    }

                    MB.Paragraph("See below for callstack and logs");
                }
            }
            MB.Paragraph(string.Format("Context: {0}", Context.ToString()));
            MB.Paragraph(string.Format("FatalErrors: {0}, Ensures: {1}, Errors: {2}, Warnings: {3}", FatalErrors, Ensures, Errors, Warnings));
            MB.Paragraph(string.Format("ResultHash: {0}", GetTestResultHash()));
            //MB.Paragraph(string.Format("Artifacts: {0}", CachedArtifactPath));
            MB.Append("--------");
            MB.Append(SB.ToString());

            //SB.Clear();
            //SB.AppendLine("begin: stack for UAT");
            //SB.Append(MB.ToString());
            //SB.Append("end: stack for UAT");
            return(MB.ToString());
        }