public async Task ExecuteAsync() { if (Interlocked.Exchange(ref _alreadyRun, RunValue) != NotRunValue) { throw new InvalidOperationException("Scenario can be run only once"); } var watch = ExecutionTimeWatch.StartNew(); try { StartScenario(); await _decoratedScenarioMethod.Invoke(); } catch (Exception ex) { HandleException(ex); } finally { StopScenario(watch); } ProcessExceptions(); }
private void StopScenario(ExecutionTimeWatch watch) { ScenarioExecutionContext.Current = null; DisposeScope(); watch.Stop(); _result.UpdateResult( _preparedSteps.Select(s => s.Result).ToArray(), watch.GetTime()); _scenarioContext.ProgressNotifier.NotifyScenarioFinished(_result); _scenarioContext.OnScenarioFinished?.Invoke(_result); }
private void StopStep(ExecutionTimeWatch watch, bool stepStartNotified) { ScenarioExecutionContext.Current.Get <CurrentStepProperty>().RemoveCurrent(this); DisposeComposite(); watch.Stop(); _result.SetExecutionTime(watch.GetTime()); _result.IncludeSubStepDetails(); if (stepStartNotified) { _stepContext.ProgressNotifier.NotifyStepFinished(_result); } }
private async Task TimeMeasuredInvokeAsync() { var watch = ExecutionTimeWatch.StartNew(); try { await _decoratingExecutor.ExecuteStepAsync(this, InvokeStepAsync, _stepDecorators); } finally { _result.SetExecutionTime(watch.GetTime()); } }
public async Task RunAsync() { var exceptionCollector = new ExceptionCollector(); _progressNotifier.NotifyScenarioStart(_info); var watch = ExecutionTimeWatch.StartNew(); try { InitializeScenario(); await _decoratingExecutor.ExecuteScenarioAsync(this, RunScenarioAsync, _scenarioDecorators); } catch (StepExecutionException ex) { _result.UpdateScenarioResult(ex.StepStatus); } catch (ScenarioExecutionException ex) when(ex.InnerException is StepBypassException) { _result.UpdateScenarioResult(ExecutionStatus.Bypassed, ex.InnerException.Message); } catch (ScenarioExecutionException ex) { _exceptionProcessor.UpdateResultsWithException(_result.UpdateScenarioResult, ex.InnerException); exceptionCollector.Capture(ex); } catch (Exception ex) { _exceptionProcessor.UpdateResultsWithException(_result.UpdateScenarioResult, ex); exceptionCollector.Capture(ex); } finally { DisposeContext(exceptionCollector); watch.Stop(); _result.UpdateResult( _preparedSteps.Select(s => s.Result).ToArray(), watch.GetTime()); _progressNotifier.NotifyScenarioFinished(Result); } ProcessExceptions(exceptionCollector); }
public async Task RunAsync() { _progressNotifier.NotifyScenarioStart(_scenario); var watch = ExecutionTimeWatch.StartNew(); try { await _extendableExecutor.ExecuteScenarioAsync(_scenario, RunScenarioAsync); } finally { watch.Stop(); _result.UpdateResult( _preparedSteps.Select(s => s.Result).ToArray(), watch.GetTime(), _scenarioInitializationException); _progressNotifier.NotifyScenarioFinished(Result); } }
private async Task TimeMeasuredInvokeAsync() { var watch = ExecutionTimeWatch.StartNew(); var ctx = AsyncStepSynchronizationContext.InstallNew(); try { try { await _stepInvocation.Invoke(_scenarioContext, PrepareParameters()); } finally { ctx.RestoreOriginal(); await ctx.WaitForTasksAsync(); } } finally { _result.SetExecutionTime(watch.GetTime()); } }
public async Task ExecuteAsync() { var stepStartNotified = false; var watch = ExecutionTimeWatch.StartNew(); try { StartStep(); stepStartNotified = true; await _decoratedStepMethod.Invoke(); UpdateStepStatus(); } catch (Exception ex) { HandleException(ex); } finally { StopStep(watch, stepStartNotified); } ProcessExceptions(); }