public void Execute(Scenario scenario, IEnumerable <IStep> steps) { _progressNotifier.NotifyScenarioStart(scenario.Name, scenario.Label); var stepsToExecute = PrepareSteps(scenario, steps); var watch = new Stopwatch(); var scenarioStartTime = DateTimeOffset.UtcNow; try { ExecutionContext.Instance = new ExecutionContext(_progressNotifier, stepsToExecute.Length); watch.Start(); ExecuteSteps(stepsToExecute); } finally { watch.Stop(); ExecutionContext.Instance = null; var result = new ScenarioResult(scenario.Name, stepsToExecute.Select(s => s.GetResult()), scenario.Label, scenario.Categories) .SetExecutionStart(scenarioStartTime) .SetExecutionTime(watch.Elapsed); if (ScenarioExecuted != null) { ScenarioExecuted.Invoke(result); } _progressNotifier.NotifyScenarioFinished(result); } }
public int Execute(CancellationTokenSource cancel = null) { int res = ExecutionEngine(cancel); ScenarioExecuted?.Invoke(this, new ScenarioEventArgs(res)); return(res); }
public Task ExecuteAsync(ScenarioInfo scenario, Func <ExtendableExecutor, object, RunnableStep[]> stepsProvider, Func <object> contextProvider, IScenarioProgressNotifier progressNotifier) { var runnableScenario = new RunnableScenario(scenario, stepsProvider, contextProvider, progressNotifier, _extendableExecutor); try { return(runnableScenario.RunAsync()); } finally { ScenarioExecuted?.Invoke(runnableScenario.Result); } }
public Task ExecuteAsync(ScenarioInfo scenario, Func <DecoratingExecutor, object, RunnableStep[]> stepsProvider, IContextProvider contextProvider, IScenarioProgressNotifier progressNotifier, IEnumerable <IScenarioDecorator> scenarioDecorators, ExceptionProcessor exceptionProcessor) { var runnableScenario = new RunnableScenario(scenario, stepsProvider, contextProvider, progressNotifier, _decoratingExecutor, scenarioDecorators, exceptionProcessor); try { return(runnableScenario.RunAsync()); } finally { ScenarioExecuted?.Invoke(runnableScenario.Result); } }
private IStep[] PrepareSteps(Scenario scenario, IEnumerable <IStep> steps) { try { return(steps.ToArray()); } catch (Exception e) { var result = new ScenarioResult(scenario.Name, new IStepResult[0], scenario.Label, scenario.Categories) .SetFailureStatus(e); if (ScenarioExecuted != null) { ScenarioExecuted.Invoke(result); } _progressNotifier.NotifyScenarioFinished(result); throw; } }