Пример #1
0
        private static XElement ToSummaryXElement(IFeatureResult[] features)
        {
            var objects = new List<object>
            {
                new XAttribute("TestExecutionStart", features.GetTestExecutionStartTime()),
                new XAttribute("TestExecutionTime", features.GetTestExecutionTime()),
                new XElement("Features", new object[] {new XAttribute("Count", features.Length)}),
                new XElement("Scenarios", new XAttribute("Count", features.CountScenarios()),
                    new XAttribute("Passed", features.CountScenariosWithStatus(ResultStatus.Passed)),
                    new XAttribute("Bypassed", features.CountScenariosWithStatus(ResultStatus.Bypassed)),
                    new XAttribute("Failed", features.CountScenariosWithStatus(ResultStatus.Failed)),
                    new XAttribute("Ignored", features.CountScenariosWithStatus(ResultStatus.Ignored))),
                new XElement("Steps", new XAttribute("Count", features.CountSteps()),
                    new XAttribute("Passed", features.CountStepsWithStatus(ResultStatus.Passed)),
                    new XAttribute("Bypassed", features.CountStepsWithStatus(ResultStatus.Bypassed)),
                    new XAttribute("Failed", features.CountStepsWithStatus(ResultStatus.Failed)),
                    new XAttribute("Ignored", features.CountStepsWithStatus(ResultStatus.Ignored)),
                    new XAttribute("NotRun", features.CountStepsWithStatus(ResultStatus.NotRun)))
            };

            return new XElement("Summary", objects);
        }
        private static void FormatSummary(StringBuilder builder, IFeatureResult[] features)
        {
            builder.AppendLine("Summary:");
            var summary = new Dictionary<string, object>
            {
                {"Test execution start time", features.GetTestExecutionStartTime().ToString("yyyy-MM-dd HH:mm:ss UTC")},
                {"Test execution time", features.GetTestExecutionTime().FormatPretty()},
                {"Number of features", features.Length},
                {"Number of scenarios", features.CountScenarios()},
                {"Passed scenarios", features.CountScenariosWithStatus(ResultStatus.Passed)},
                {"Bypassed scenarios", features.CountScenariosWithStatus(ResultStatus.Bypassed)},
                {"Failed scenarios", features.CountScenariosWithStatus(ResultStatus.Failed)},
                {"Ignored scenarios", features.CountScenariosWithStatus(ResultStatus.Ignored)},
                {"Number of steps", features.CountSteps()},
                {"Passed steps", features.CountStepsWithStatus(ResultStatus.Passed)},
                {"Bypassed steps", features.CountStepsWithStatus(ResultStatus.Bypassed)},
                {"Failed steps", features.CountStepsWithStatus(ResultStatus.Failed)},
                {"Ignored steps", features.CountStepsWithStatus(ResultStatus.Ignored)},
                {"Not Run steps", features.CountStepsWithStatus(ResultStatus.NotRun)}
            };

            var maxLength = summary.Keys.Max(k => k.Length);
            var format = string.Format("\t{{0,-{0}}}: {{1}}", maxLength);
            foreach (var row in summary)
                builder.AppendFormat(format, row.Key, row.Value).AppendLine();
        }