コード例 #1
0
        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();
        }
コード例 #2
0
        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);
        }
コード例 #3
0
ファイル: RunnableStep.cs プロジェクト: LightBDD/LightBDD
 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);
     }
 }
コード例 #4
0
        private async Task TimeMeasuredInvokeAsync()
        {
            var watch = ExecutionTimeWatch.StartNew();

            try
            {
                await _decoratingExecutor.ExecuteStepAsync(this, InvokeStepAsync, _stepDecorators);
            }
            finally
            {
                _result.SetExecutionTime(watch.GetTime());
            }
        }
コード例 #5
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);
        }
コード例 #6
0
        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);
            }
        }
コード例 #7
0
        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());
            }
        }
コード例 #8
0
ファイル: RunnableStep.cs プロジェクト: LightBDD/LightBDD
        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();
        }