Exemple #1
0
        public async Task RunAsync()
        {
            var exceptionCollector = new ExceptionCollector();
            var stepStartNotified  = false;

            try
            {
                EvaluateParameters();
                _progressNotifier.NotifyStepStart(_result.Info);
                stepStartNotified = true;

                await TimeMeasuredInvokeAsync();

                _result.SetStatus(_result.GetSubSteps().GetMostSevereOrNull()?.Status ?? ExecutionStatus.Passed);
            }
            catch (StepExecutionException e)
            {
                _result.SetStatus(e.StepStatus);
            }
            catch (ScenarioExecutionException exception) when(exception.InnerException is StepBypassException)
            {
                _result.SetStatus(ExecutionStatus.Bypassed, exception.InnerException.Message);
            }
            catch (ScenarioExecutionException exception)
            {
                _exceptionProcessor.UpdateResultsWithException(_result.SetStatus, exception.InnerException);
                exceptionCollector.Capture(exception);
            }
            catch (Exception exception)
            {
                _exceptionProcessor.UpdateResultsWithException(_result.SetStatus, exception);
                exceptionCollector.Capture(exception);
            }
            finally
            {
                DisposeCompositeStep(exceptionCollector);
                _result.IncludeSubStepDetails();
                if (stepStartNotified)
                {
                    _progressNotifier.NotifyStepFinished(_result);
                }
            }
            ProcessExceptions(exceptionCollector);
        }
Exemple #2
0
        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);
        }