Ejemplo n.º 1
0
 internal ScenarioRunner(Scenario scenario, CoreFactory factory)
 {
     this.scenario = scenario;
     this.factory = factory;
     stepExecutor = factory.CreateStepExecutor(scenario);
     statsCascader = factory.UtilityFactory.CreateStatsCascader();
 }
Ejemplo n.º 2
0
 internal ScenarioBuilder(string scenarioName, Feature feature, CoreFactory factory)
 {
     this.factory = factory;
     outcomeAggregator = factory.UtilityFactory.CreateOutcomeAggregator();
     scenario = factory.CreateScenario(scenarioName, feature);
     runner = factory.CreateScenarioRunner(scenario);
 }
Ejemplo n.º 3
0
        internal static HtmlReportLineItem GetHtmlReportLineItem(this xBDD.Model.Scenario scenario)
        {
            var li = new HtmlReportLineItem();

            li.ChildItems    = new List <HtmlReportLineItem>();
            li.ChildStats    = scenario.StepStats;
            li.ChildTypeName = "scenarios";
            li.EndTime       = scenario.EndTime;
            li.StartTime     = scenario.StartTime;
            li.Name          = scenario.Name.HtmlEncode();
            li.Outcome       = scenario.Outcome;
            li.Reason        = scenario.Reason;
            li.Assignments   = scenario.Assignments.ToList();
            li.Tags          = scenario.Tags.ToList();
            Dictionary <string, Dictionary <string, int> > reasonStats = new Dictionary <string, Dictionary <string, int> >();

            li.ReasonStats = reasonStats;
            li.TypeName    = "scenario";
            foreach (var step in scenario.Steps)
            {
                li.ChildItems.Add(step.GetHtmlReportLineItem());
            }
            li.Explanation       = scenario.Explanation;
            li.ExplanationFormat = scenario.ExplanationFormat;
            return(li);
        }
Ejemplo n.º 4
0
        private void WriteScenario(Scenario lastScenario, Scenario scenario, StringBuilder sb)
        {
            if(lastScenario == null || (lastScenario != null && lastScenario.Feature.Area.Name != scenario.Feature.Area.Name))
            {
                sb.AppendLine(scenario.Feature.Area.Name);
            }

            if (lastScenario == null || (lastScenario != null && lastScenario.Feature.Name != scenario.Feature.Name))
            {
                sb.Append("\t");
                sb.AppendLine(scenario.Feature.Name);
            }
            sb.Append("\t\t");
            sb.Append(scenario.Name);
            if (scenario.Outcome != Outcome.Passed)
            {
                sb.Append(" [");
                sb.Append(Enum.GetName(typeof(Outcome), scenario.Outcome));
                if (scenario.Reason != null && scenario.Reason != "Failed Step")
                {
                    sb.Append(" - ");
                    sb.Append(scenario.Reason);
                }
                sb.AppendLine("]");

            }
            else
                sb.AppendLine();
            foreach(var step in scenario.Steps)
            {
                WriteStep(step, sb);
            }
        }
Ejemplo n.º 5
0
        private void CascadeAreaOutcome(Scenario scenario)
        {
            var areaOutcome = scenario.Feature.Area.Outcome;
            scenario.Feature.Area.Outcome = outcomeAggregator.GetNewParentOutcome(
				scenario.Feature.Area.Outcome, scenario.Feature.Outcome);
            UpdateOutcome(areaOutcome, scenario.Feature.Area.Outcome,
                scenario.Feature.Area.TestRun.AreaStats);
        }
Ejemplo n.º 6
0
 private void BuildSteps(xb.Scenario scenario, Scenario scenarioDb)
 {
     foreach (var step in scenario.Steps)
     {
         Step stepDb = factory.CreateStep(step, scenarioDb);
         stepDb.Scenario = scenarioDb;
         dbContext.Steps.Add(stepDb);
     }
 }
Ejemplo n.º 7
0
        void CascadeOutcome(Scenario scenario)
        {
            UpdateOutcome(Outcome.NotRun, scenario.Outcome,
                scenario.Feature.ScenarioStats,
                scenario.Feature.Area.ScenarioStats,
                scenario.Feature.Area.TestRun.ScenarioStats);
			CascadeFeatureOutcome(scenario);
			CascadeAreaOutcome(scenario);
            scenario.Feature.Area.TestRun.Outcome = outcomeAggregator.GetNewParentOutcome(scenario.Feature.Area.Outcome, scenario.Feature.Outcome);
        }
Ejemplo n.º 8
0
 internal Scenario CreateScenario(string name, Feature feature)
 {
     var scenario = new Scenario()
     {
         Name = name,
         Feature = feature,
         StepStats = new OutcomeStats()
     };
     feature.Scenarios.Add(scenario);
     return scenario;
 }
Ejemplo n.º 9
0
 internal Scenario CreateScenario(xb.Scenario scenario, TestRun testRun)
 {
     return(new Scenario()
     {
         CapabilityPath = scenario.Feature.Capability.Name,
         FeatureName = scenario.Feature.Name,
         Name = scenario.Name,
         Outcome = scenario.Outcome,
         Reason = scenario.Reason,
         EndTime = scenario.EndTime,
         TestRun = testRun,
         StartTime = scenario.StartTime
     });
 }
Ejemplo n.º 10
0
 internal StepExecutor CreateStepExecutor(Scenario scenario)
 {
     return new StepExecutor(scenario, this);
 }
Ejemplo n.º 11
0
 internal StepExceptionHandler CreateStepExceptionHandler(Scenario scenario)
 {
     return new StepExceptionHandler(scenario, this);
 }
Ejemplo n.º 12
0
 internal ScenarioRunner CreateScenarioRunner(Scenario scenario)
 {
     return new ScenarioRunner(scenario, this);
 }
Ejemplo n.º 13
0
 public ScenarioOutputWriter(Scenario scenario, IOutputWriter outputWriter)
 {
     this.scenario = scenario;
     this.outputWriter = outputWriter;
 }
Ejemplo n.º 14
0
 public StepExecutor(Scenario scenario, CoreFactory factory)
 {
     stepExceptionHandler = factory.CreateStepExceptionHandler(scenario);
     statsCascader = factory.UtilityFactory.CreateStatsCascader();
     this.scenario = scenario;
 }
Ejemplo n.º 15
0
		public void CascadeStats(Scenario scenario)
		{
			CascadeOutcome(scenario);
			CascadeStartTime(scenario);
			CascadeEndTime(scenario);
		}
Ejemplo n.º 16
0
        void WriteAreaOpen(Scenario scenario, StringBuilder sb)
        {
            string style = null;
            string className = null;
            switch (scenario.Feature.Area.Outcome)
            {
                case Outcome.NotRun:
                    style = "#949494";
                    className = "text-muted";
                    break;
                case Outcome.Passed:
                    style = "#5A8B5B";
                    className = "text-success collapsed";
                    break;
                case Outcome.Failed:
                    style = "#AD4D4B";
                    className = "text-danger";
                    break;
                case Outcome.Skipped:
                    style = "#917545";
                    className = "text-warning";
                    break;
                default:
                    break;
            }
            style = "border-left: 2px solid "+style+";";
            //  style = "box-shadow: inset 1px 1px 8px 1px "+style+";";
            areaCounter++;
            var expanded = scenario.Feature.Area.Outcome == Outcome.Failed;
            var expandedText = expanded ? "true" : "false";
            WriteTagOpen("li", sb, 2, "area", false, "area-" + areaCounter);

            var areaTitleAttributes = String.Format("data-toggle=\"collapse\" href=\"#area-{0}-features\" aria-expanded=\"{1}\" aria-controls=\"area-{0}-features\" ", areaCounter, expandedText);
            WriteTagOpen("h2", sb, 3, className, true, null, null, areaTitleAttributes);
            WriteTag("small", sb, 4, null, "Area", true);
            WriteTag("span", sb, 4, "name pointer", scenario.Feature.Area.Name.HtmlEncode(), true);
            WriteTag("span", sb, 4, "badge pull-right total", scenario.Feature.Area.FeatureStats.Total.ToString(), true, null, null, "title=\"Features\"");
            WriteTagClose("h2", sb, 3);

            WriteStatsTableStart(sb, 3);
            WriteStats(sb, scenario.Feature.Area.FeatureStats, 3, "area-"+areaCounter+"-feature-stats", "Features");
            WriteStats(sb, scenario.Feature.Area.ScenarioStats, 3, "area-"+areaCounter+"-scenario-stats", "Scenarios");
            WriteStatsTableClose(sb, 3);

            var featuresClasName = "features list-unstyled collapse" + (expanded ? " in" : "");
            WriteTagOpen("ol", sb, 3, featuresClasName, false, "area-" + areaCounter + "-features", style, String.Format("aria-expanded=\"{0}\"", expandedText));
        }
Ejemplo n.º 17
0
        void WriteSteps(Scenario scenario, StringBuilder sb)
        {
            var expanded = scenario.Outcome == Outcome.Failed;
            var expandedText = expanded ? "true" : "false";

            var scenariosClassName = "panel-body collapse" + (expanded ? " in" : "");
            WriteTagOpen("div", sb, 7, scenariosClassName, false, "scenario-" + scenarioCounter + "-steps", null, String.Format("aria-expanded=\"{0}\"", expandedText));
            WriteTagOpen("ol", sb, 7, "steps list-unstyled", false);
            foreach(Step step in scenario.Steps)
            {
                stepCounter++;
                WriteStep(step, sb, stepCounter);
            }
            WriteTagClose("ol", sb, 7);
            WriteTagClose("div", sb, 7);
        }
Ejemplo n.º 18
0
        void CascadeEndTime(Scenario scenario)
        {
			if(scenario.Feature.EndTime > DateTime.MinValue)
            	scenario.Feature.EndTime =  scenario.EndTime;
			if(scenario.Feature.Area.EndTime > DateTime.MinValue)
            	scenario.Feature.Area.EndTime = scenario.EndTime;
			if(scenario.Feature.Area.TestRun.EndTime > DateTime.MinValue)
            	scenario.Feature.Area.TestRun.EndTime = scenario.EndTime;
        }
Ejemplo n.º 19
0
 void WriteScenarioOpen(Scenario scenario, StringBuilder sb)
 {
     var className = "scenario " + Enum.GetName(typeof(Outcome), scenario.Outcome).ToLower();
     var panelClassName = "panel ";
     switch (scenario.Outcome)
     {
         case Outcome.NotRun:
             break;
         case Outcome.Passed:
             panelClassName = panelClassName + " panel-success";
             break;
         case Outcome.Failed:
             panelClassName = panelClassName + " panel-danger";
             break;
         case Outcome.Skipped:
             panelClassName = panelClassName + " panel-warning";
             break;
         default:
             break;
     }
     scenarioCounter++;
     WriteTagOpen("li", sb, 6, className, false, "scenario-" + scenarioCounter);
     WriteTagOpen("div", sb, 7, panelClassName, false);
 }
Ejemplo n.º 20
0
 void WriteFeatureStatement(Scenario scenario, StringBuilder sb)
 {
     if(scenario.Feature.Actor != null || scenario.Feature.Value != null || scenario.Feature.Capability != null)
     {
         var statement = $"In order to {scenario.Feature.Value??"[Missing!]"}\r\nAs a {scenario.Feature.Actor??"[Missing!]"}\r\nI would like to {scenario.Feature.Capability??"[Missing!]"}";
         WriteTag("pre", sb, 5, "feature-statement", statement, true, $"feature-{featureCounter}-statement");
     }
 }
Ejemplo n.º 21
0
        void WriteFeatureOpen(Scenario scenario, StringBuilder sb)
        {
            string style = null;
            string className = null;
            switch (scenario.Feature.Outcome)
            {
                case Outcome.NotRun:
                    style = "#949494";
                    className = "text-muted";
                    break;
                case Outcome.Passed:
                    style = "#5A8B5B";
                    className = "text-success";
                    break;
                case Outcome.Failed:
                    style = "#AD4D4B";
                    className = "text-danger";
                    break;
                case Outcome.Skipped:
                    style = "#917545";
                    className = "text-warning";
                    break;
                default:
                    break;
            }
            style = "box-shadow: 1px 1px 8px 1px "+style+";";
            featureCounter++;
            var expanded = scenario.Feature.Outcome == Outcome.Failed;
            var expandedText = expanded ? "true" : "false";
            WriteTagOpen("li", sb, 4, "feature", false, "feature-" + featureCounter, style);

            var titleAttributes = String.Format("data-toggle=\"collapse\" href=\"#feature-{0}-scenarios\" aria-expanded=\"{1}\" aria-controls=\"feature-{0}-scenarios\" ", featureCounter, expandedText);
            WriteTagOpen("h3", sb, 5, className, true, "vertical-align: top !important;", null, titleAttributes);
            WriteTag("small", sb, 6,null, "Feature", true);
            WriteTag("span", sb, 6, "name pointer", scenario.Feature.Name.HtmlEncode(), true);
            WriteTag("span", sb, 6, "badge pull-right total", scenario.Feature.ScenarioStats.Total.ToString(), true, null, null, "title=\"Scenarios\"");
            WriteTagClose("h3", sb, 5);

            WriteStatsTableStart(sb, 5);
            WriteStats(sb, scenario.Feature.ScenarioStats, 5, "feature-"+featureCounter+"-scenario-stats", "Scenarios");
            WriteStatsTableClose(sb, 5);
            
            WriteFeatureStatement(scenario, sb);

            var scenariosClassName = "scenarios list-unstyled collapse" + (expanded ? " in" : "");
            WriteTagOpen("ol", sb, 5, scenariosClassName, false, "feature-" + featureCounter + "-scenarios", null, String.Format("aria-expanded=\"{0}\"", expandedText));
        }
Ejemplo n.º 22
0
 internal ScenarioOutputWriter CreateScenarioOutputWriter(Scenario scenario, IOutputWriter outputWriter)
 {
     return new ScenarioOutputWriter(scenario, outputWriter);
 }
Ejemplo n.º 23
0
        void WriteAreaFeatureAndScenario(Scenario lastScenario, Scenario scenario, StringBuilder sb)
        {
            if (lastScenario == null || (lastScenario != null && lastScenario.Feature.Area.Name != scenario.Feature.Area.Name))
            {
                if (lastScenario != null)
                {
                    WriteFeatureClose(sb);
                    WriteAreaClose(sb);
                }
                WriteAreaOpen(scenario, sb);
                WriteFeatureOpen(scenario, sb);
            }
            else if (lastScenario == null || (lastScenario != null && lastScenario.Feature.Name != scenario.Feature.Name))
            {
                if (lastScenario != null)
                {
                    WriteFeatureClose(sb);
                }
                WriteFeatureOpen(scenario, sb);
            }

            WriteScenario(scenario, sb);
        }
Ejemplo n.º 24
0
        void WriteScenarioTitleLine(Scenario scenario, StringBuilder sb)
        {
            var expanded = scenario.Outcome == Outcome.Failed;
            var expandedText = expanded ? "true" : "false";

            var titleAttributes = String.Format("data-toggle=\"collapse\" href=\"#scenario-{0}-steps\" aria-expanded=\"{1}\" aria-controls=\"scenario-{0}-steps\" ", scenarioCounter, expandedText);
            WriteTagOpen("div", sb, 7, "panel-heading", true, null, null, titleAttributes);
            WriteTag("span", sb, 0, "name pointer", scenario.Name.HtmlEncode(), true);
            if (scenario.Outcome != Outcome.Passed)
            {
                WriteScenarioStatus(scenario, sb);
            }

            WriteTag("span", sb, 8, "badge pull-right total", scenario.StepStats.Total.ToString(), true, null, null, "title=\"Steps\"");

            WriteTagClose("div", sb, 0);
        }
Ejemplo n.º 25
0
 private void WriteScenario(Scenario scenario, StringBuilder sb)
 {
     WriteScenarioOpen(scenario, sb);
     WriteScenarioTitleLine(scenario, sb);
     if (scenario.Steps.Count > 0)
     {
         WriteSteps(scenario, sb);
     }
     WriteScenarioClose(sb);
 }
Ejemplo n.º 26
0
 void WriteScenarioStatus(Scenario scenario, StringBuilder sb)
 {
     WriteTagOpen("span",sb, 0, "status", true);
     sb.Append("[");
     sb.Append(Enum.GetName(typeof(Outcome), scenario.Outcome));
     if (scenario.Reason != null && scenario.Reason != "Failed Step")
     {
         sb.Append(" - ");
         sb.Append(scenario.Reason.HtmlEncode());
     }
     sb.Append("]");
     WriteTagClose("span", sb, 0);
 }
Ejemplo n.º 27
0
        void CascadeStartTime(Scenario scenario)
        {
			if(scenario.Feature.StartTime.Equals(DateTime.MinValue) || scenario.Feature.StartTime > scenario.StartTime)
            	scenario.Feature.StartTime = scenario.StartTime;
			if(scenario.Feature.Area.StartTime.Equals(DateTime.MinValue) || scenario.Feature.Area.StartTime > scenario.StartTime)
            	scenario.Feature.Area.StartTime = scenario.StartTime;
			if(scenario.Feature.Area.TestRun.StartTime.Equals(DateTime.MinValue) || scenario.Feature.Area.TestRun.StartTime > scenario.StartTime)
            	scenario.Feature.Area.TestRun.StartTime =  scenario.StartTime;
        }