Exemplo n.º 1
0
        public SpecResults Execute(SpecExecutionRequest request, IConsumingQueue queue)
        {
            _mode.BeforeRunning(request);

            if (Status == SpecRunnerStatus.Invalid)
            {
                var abortedResults = SpecResults.ForAbortedRun(request.Id);
                _mode.AfterRunning(request, abortedResults, queue, Status);

                return(abortedResults);
            }

            request.Plan.Attempts++;

            var timings = request.StartNewTimings();

            SpecResults results = null;

            try
            {
                Current = request.Mode == ExecutionMode.normal
                    ? new SpecExecution(request, _stopConditions, _mode.BuildLogger())
                    : new StepthroughExecution(request, _stopConditions, _mode.Observer(), _observer);

                _observer.SpecStarted(request);

                results = Current.Execute(_system, timings);
            }
            catch (Exception ex) // Any exception that bubbles up is telling us that the runner is invalid
            {
                MarkAsInvalid(ex);

                results = buildResultsForContextCreationFailure(request, ex, timings);
            }
            finally
            {
                _mode.AfterRunning(request, results, queue, Status);

                timings.Dispose();
            }

            return(results);
        }
Exemplo n.º 2
0
        public SpecResults Execute(SpecExecutionRequest request, IConsumingQueue queue)
        {
            _mode.BeforeRunning(request);

            if (Status == SpecRunnerStatus.Invalid)
            {
                var abortedResults = SpecResults.ForAbortedRun(request.Id);
                _mode.AfterRunning(request, abortedResults, queue, Status);

                return abortedResults;
            }

            request.Plan.Attempts++;

            var timings = request.StartNewTimings();

            SpecResults results = null;

            try
            {
                Current = request.Mode == ExecutionMode.normal
                    ? new SpecExecution(request, _stopConditions, _mode.BuildLogger())
                    : new StepthroughExecution(request, _stopConditions, _mode.Observer(), _observer);

                _observer.SpecStarted(request);

                results = Current.Execute(_system, timings);
            }
            catch (Exception ex) // Any exception that bubbles up is telling us that the runner is invalid
            {
                MarkAsInvalid(ex);

                results = buildResultsForContextCreationFailure(request, ex, timings);
            }
            finally
            {
                _mode.AfterRunning(request, results, queue, Status);

                timings.Dispose();
            }

            return results;
        }