예제 #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);
            }
            if (_specExpiration.IsExpired(request.Specification))
            {
                var expiredResults = SpecResults.ForExpiredRun(request.Id);
                _mode.AfterRunning(request, expiredResults, queue, Status);
                return(expiredResults);
            }

            request.Plan.Attempts++;

            var timings = request.StartNewTimings();

            SpecResults results = null;

            try
            {
                _current = new ExecutionRun(_system, timings, request, _stopConditions, _mode);
                results  = _current.Execute();
            }
            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();
                if (_current != null)
                {
                    _current.SafeDispose();
                }
            }

            return(results);
        }
예제 #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);
        }