Пример #1
0
 void ProcessNotImplementedException(StepExecutor stepExecutor, Step step, NotImplementedException ex)
 {
     step.EndTime   = DateTime.Now;
     step.Outcome   = Outcome.Failed;
     step.Reason    = "Failed";
     step.Exception = ex;
     if (scenario.Reason == null)
     {
         scenario.Reason = "Failed";
     }
     statsCascader.CascadeStepStats(step, false);
     throw new StepNotImplementedException(step.Name, ex);
 }
Пример #2
0
 private void PostExecution(Step step)
 {
     step.EndTime = DateTime.Now;
     step.Outcome = Outcome.Passed;
     step.Reason  = "Passed";
     statsCascader.CascadeStepStats(step, false);
 }
Пример #3
0
        public async Task RunAsync(bool passWhenNoAction)
        {
            scenario.StartTime = DateTime.Now;
            if (outputWriter != null)
            {
                outputWriter.WriteOutput();
            }

            if (scenario.Steps.Count() == 0)
            {
                ProcessScenarioWhenThereAreNoSteps();
            }
            else
            {
                try
                {
                    foreach (var step in scenario.Steps)
                    {
                        if (passWhenNoAction)
                        {
                            step.Outcome   = Outcome.Passed;
                            step.Reason    = "Passed";
                            step.StartTime = DateTime.Now;
                            step.EndTime   = step.StartTime;
                            statsCascader.CascadeStepStats(step, false);
                        }
                        else
                        {
                            if (step.ActionAsync == null && step.Action == null)
                            {
                                var notImplementedException = new NotImplementedException();
                                var ex = new StepNotImplementedException(step.Name, notImplementedException);
                                step.StartTime = DateTime.Now;
                                step.EndTime   = step.StartTime;
                                step.Outcome   = Outcome.Failed;
                                step.Exception = ex;
                                step.Reason    = "Failed";
                                statsCascader.CascadeStepStats(step, false);
                                throw ex;
                            }
                            await stepExecutor.ExecuteStepAsync(step);
                        }
                    }
                }
                catch
                {
                    foreach (var step in scenario.Steps)
                    {
                        if (step.Outcome == Outcome.NotRun)
                        {
                            step.StartTime = DateTime.Now;
                            step.EndTime   = step.StartTime;
                            step.Outcome   = Outcome.Skipped;
                            step.Reason    = "Previous Error";
                            statsCascader.CascadeStepStats(step, false);
                        }
                    }
                    scenario.EndTime = DateTime.Now;
                    throw;
                }
            }
            scenario.EndTime = DateTime.Now;
        }