Пример #1
0
        private static IHtmlNode GetFeatureSummary(IFeatureResult feature, int index)
        {
            var timeSummary = feature.GetScenarios().GetTestExecutionTimeSummary();

            return(Html.Tag(Html5Tag.Tr).Content(
                       Html.Tag(Html5Tag.Td).Content(
                           Html.Tag(Html5Tag.A).Href("#feature" + index).Content(feature.Info.Name.Format(StepNameDecorator)),
                           Html.Tag(Html5Tag.Span).Content(feature.Info.Labels.Select(GetLabel)).SkipEmpty()),

                       Html.Tag(Html5Tag.Td).Content(feature.GetScenarios().Count().ToString()),
                       Html.Tag(Html5Tag.Td).Content(feature.CountScenariosWithStatus(ExecutionStatus.Passed).ToString()),
                       GetNumericTagWithOptionalClass(Html5Tag.Td, "bypassedAlert", feature.CountScenariosWithStatus(ExecutionStatus.Bypassed)),
                       GetNumericTagWithOptionalClass(Html5Tag.Td, "failedAlert", feature.CountScenariosWithStatus(ExecutionStatus.Failed)),
                       GetNumericTagWithOptionalClass(Html5Tag.Td, "ignoredAlert", feature.CountScenariosWithStatus(ExecutionStatus.Ignored)),

                       Html.Tag(Html5Tag.Td).Content(feature.CountSteps().ToString()),
                       Html.Tag(Html5Tag.Td).Content(feature.CountStepsWithStatus(ExecutionStatus.Passed).ToString()),
                       GetNumericTagWithOptionalClass(Html5Tag.Td, "bypassedAlert", feature.CountStepsWithStatus(ExecutionStatus.Bypassed)),
                       GetNumericTagWithOptionalClass(Html5Tag.Td, "failedAlert", feature.CountStepsWithStatus(ExecutionStatus.Failed)),
                       GetNumericTagWithOptionalClass(Html5Tag.Td, "ignoredAlert", feature.CountStepsWithStatus(ExecutionStatus.Ignored)),
                       Html.Tag(Html5Tag.Td).Content(feature.CountStepsWithStatus(ExecutionStatus.NotRun).ToString()),

                       Html.Tag(Html5Tag.Td).Content(timeSummary.Duration.FormatPretty()),
                       Html.Tag(Html5Tag.Td).Class("hidden").Content(timeSummary.Duration.Ticks.ToString()),
                       Html.Tag(Html5Tag.Td).Content(timeSummary.Aggregated.FormatPretty()),
                       Html.Tag(Html5Tag.Td).Class("hidden").Content(timeSummary.Aggregated.Ticks.ToString()),
                       Html.Tag(Html5Tag.Td).Content(timeSummary.Average.FormatPretty()),
                       Html.Tag(Html5Tag.Td).Class("hidden").Content(timeSummary.Average.Ticks.ToString())
                       ));
        }
Пример #2
0
 private IHtmlNode GetFeatureDetails(IFeatureResult feature, int index)
 {
     return(Html.Tag(Html5Tag.Article).Class(GetFeatureClasses(feature)).Content(
                Html.Checkbox().Class("toggle toggleF").Id("toggle" + index).Checked(),
                Html.Tag(Html5Tag.Div).Class("header").Content(
                    Html.Tag(Html5Tag.H2).Id("feature" + index).Class("title").Content(
                        Html.Tag(Html5Tag.Label).For("toggle" + index).Content(GetCheckBoxTag(), Html.Text(feature.Info.Name.Format(StepNameDecorator))),
                        Html.Tag(Html5Tag.Span).Content(feature.Info.Labels.Select(GetLabel)).SkipEmpty(),
                        GetSmallLink("feature" + index)),
                    Html.Tag(Html5Tag.Div).Class("description").Content(feature.Info.Description)),
                Html.Tag(Html5Tag.Div).Class("scenarios").Content(
                    feature.GetScenarios().Select((s, i) => GetScenario(s, index, i)))));
 }
Пример #3
0
        private static string GetFeatureClasses(IFeatureResult feature)
        {
            var builder = new StringBuilder("feature");

            foreach (var result in Enum.GetValues(typeof(ExecutionStatus)).Cast <ExecutionStatus>().Where(result => feature.CountScenariosWithStatus(result) > 0))
            {
                builder.Append(" ").Append(GetStatusClass(result));
            }

            if (!feature.GetScenarios().Any())
            {
                builder.Append(" ").Append(GetStatusClass(ExecutionStatus.NotRun));
            }

            return(builder.ToString());
        }
Пример #4
0
        private static XElement ToXElement(IFeatureResult feature)
        {
            var objects = new List <object> {
                new XAttribute("Name", feature.Info.Name)
            };

            objects.AddRange(feature.Info.Labels.Select(label => new XElement("Label", new XAttribute("Name", label))));

            if (!string.IsNullOrWhiteSpace(feature.Info.Description))
            {
                objects.Add(new XElement("Description", feature.Info.Description));
            }

            objects.AddRange(feature.GetScenarios().Select(ToXElement));

            return(new XElement("Feature", objects));
        }
Пример #5
0
        private static void FormatFeature(TextWriter writer, IFeatureResult feature)
        {
            writer.WriteLine();
            writer.Write("Feature: ");
            writer.Write(feature.Info.Name);
            FormatLabels(writer, feature.Info.Labels);

            writer.WriteLine();

            if (!string.IsNullOrWhiteSpace(feature.Info.Description))
            {
                writer.Write("\t");
                writer.Write(feature.Info.Description.Replace(Environment.NewLine, Environment.NewLine + "\t"));
                writer.WriteLine();
            }

            foreach (var scenario in feature.GetScenarios())
            {
                FormatScenario(writer, scenario);
            }
        }
 public void NotifyFeatureFinished(IFeatureResult feature)
 {
     _notifications.Add($"Feature Finish: {FormatFeature(feature.Info)} | Scenarios:{feature.GetScenarios().Count()}");
 }
Пример #7
0
 /// <summary>
 /// Counts all steps with given status.
 /// </summary>
 public static int CountStepsWithStatus(this IFeatureResult result, ExecutionStatus status)
 {
     return(result.GetScenarios().Sum(s => s.CountStepsWithStatus(status)));
 }
Пример #8
0
 /// <summary>
 /// Counts all steps.
 /// </summary>
 public static int CountSteps(this IFeatureResult result)
 {
     return(result.GetScenarios().SelectMany(s => s.GetAllSteps()).Count());
 }
Пример #9
0
 /// <summary>
 /// Returns scenarios ordered by name.
 /// </summary>
 public static IEnumerable <IScenarioResult> GetScenariosOrderedByName(this IFeatureResult feature)
 {
     return(feature.GetScenarios().OrderBy(s => s.Info.Name.ToString(), StringComparer.OrdinalIgnoreCase));
 }