void ReportOnStep(Scenario scenario, ExecutionStep step)
        {
            var message =
                string.Format
                    ("\t{0}  [{1}] ",
                    PrefixWithSpaceIfRequired(step).PadRight(_longestStepSentence + 5),
                    Configurator.Scanners.Humanize(step.Result.ToString()));

            // if all the steps have passed, there is no reason to make noise
            if (scenario.Result == StepExecutionResult.Passed)
                message = "\t" + PrefixWithSpaceIfRequired(step);

            if (step.Exception != null)
            {
                _exceptions.Add(step.Exception);

                var exceptionReference = string.Format("[Details at {0} below]", _exceptions.Count);
                if (!string.IsNullOrEmpty(step.Exception.Message))
                    message += string.Format("[{0}] {1}", FlattenExceptionMessage(step.Exception.Message), exceptionReference);
                else
                    message += string.Format("{0}", exceptionReference);
            }

            if (step.Result == StepExecutionResult.Inconclusive || step.Result == StepExecutionResult.NotImplemented)
                Console.ForegroundColor = ConsoleColor.Yellow;
            else if (step.Result == StepExecutionResult.Failed)
                Console.ForegroundColor = ConsoleColor.Red;
            else if (step.Result == StepExecutionResult.NotExecuted)
                Console.ForegroundColor = ConsoleColor.Gray;

            Console.WriteLine(message);
            Console.ForegroundColor = ConsoleColor.White;
        }
예제 #2
0
 /// <summary>
 /// Runs all the dispose methods in the scenario
 /// </summary>
 /// <param name="scenario"></param>
 private static void Dispose(Scenario scenario)
 {
     var disposeSteps = scenario
         .Steps
         .Where(s => s.ExecutionOrder == ExecutionOrder.TearDown && s.Result == StepExecutionResult.NotExecuted);
     
     foreach (var disposeStep in disposeSteps)
     {
         scenario.ExecuteStep(disposeStep);
     }
 }
 public void Setup()
 {
     _sut = new ScenarioWithMixedSteps();
     _scenario = 
         new ReflectiveScenarioScanner(
             new IStepScanner[]
                 {
                     new ExecutableAttributeStepScanner(),
                     new DefaultMethodNameStepScanner()
                 }).Scan(_sut);          
 }
예제 #4
0
        private void AddScenario(Scenario scenario)
        {
            using (OpenTag(string.Format("<div class='scenario'>"), HtmlTag.div))
            {
                AddLine(string.Format("<div class='{0} canToggle scenarioTitle' data-toggle-target='{1}'>{2}</div>", scenario.Result, scenario.Id, scenario.Title));

                using (OpenTag(string.Format("<ul class='steps' id='{0}'>", scenario.Id), HtmlTag.ul))
                {
                    foreach (var step in scenario.Steps.Where(s => s.ShouldReport))
                    {
                        string stepClass = string.Empty;
                        var reportException = step.Exception != null && step.Result == StepExecutionResult.Failed;
                        string canToggle = reportException ? "canToggle" : string.Empty;

                        using (OpenTag(string.Format("<li class='step {0} {1} {2} {3}' data-toggle-target='{4}' >", step.Result, stepClass, step.ExecutionOrder, canToggle, step.Id), HtmlTag.li))
                        {
                            var titleLines = step.StepTitle.Split(new[] {Environment.NewLine}, StringSplitOptions.None);
                            var title = titleLines[0];
                            if (reportException)
                            {
                                stepClass = step.Result + "Exception";
                                if (!string.IsNullOrEmpty(step.Exception.Message))
                                {
                                    title += " [Exception Message: '" + step.Exception.Message + "']";
                                }
                            }

                            AddLine(string.Format("<span>{0}</span>", title));

                            for (int i = 1; i < titleLines.Length; i++)
                            {
                                AddLine(string.Format("<div class='step-title-extra-lines'>{0}</div>", titleLines[i]));
                            }

                            if (reportException)
                            {
                                using (OpenTag(string.Format("<div class='step {0}' id='{1}'>", stepClass, step.Id), HtmlTag.div))
                                {
                                    AddLine(string.Format("<code>{0}</code>", step.Exception.StackTrace));
                                }
                            }
                        }
                    }
                }
            }
        }
 public void InconclusiveExceptionSetup()
 {
     _engine = new InconclusiveTestClass().LazyBDDfy();
     Assert.Throws<InconclusiveException>(() => _engine.Run());
     _scenario = _engine.Story.Scenarios.First();
 }
 static void Report(Scenario scenario)
 {
     Console.ForegroundColor = ConsoleColor.White;
     Console.WriteLine();
     Console.WriteLine("Scenario: " + scenario.Title);
 }