public void AfterRunning(SpecExecutionRequest request, SpecResults results, IConsumingQueue queue, SpecRunnerStatus status)
 {
     if (ShouldRetry(results, request.Specification, status))
     {
         _resultObserver.SpecRequeued(request);
         queue.Enqueue(request);
     }
     else
     {
         _resultObserver.SpecHandled(request, results);
     }
 }
Beispiel #2
0
 public void AfterRunning(SpecExecutionRequest request, SpecResults results, IConsumingQueue queue, SpecRunnerStatus status)
 {
     if (ShouldRetry(results, request.Specification, status))
     {
         _resultObserver.SpecRequeued(request);
         queue.Enqueue(request);
     }
     else
     {
         _resultObserver.SpecHandled(request, results);
     }
 }
Beispiel #3
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);
        }
Beispiel #4
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);
        }
Beispiel #5
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;
        }
Beispiel #6
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;
        }
Beispiel #7
0
        public executing_a_spec_when_context_creation_blows_up()
        {
            var specNode = new Specification()
            {
                id = Guid.NewGuid().ToString()
            };

            theRequest = new SpecExecutionRequest(specNode, new NulloResultObserver());

            theRequest.CreatePlan(TestingContext.Library);

            theQueue = MockFor <IConsumingQueue>();

            theException = new DivideByZeroException("Wrong!");

            MockFor <ISystem>().CreateContext().Throws(theException);

            ClassUnderTest.Status.ShouldBe(SpecRunnerStatus.Valid);

            theResults = ClassUnderTest.Execute(theRequest, theQueue);
        }
        protected override void beforeEach()
        {
            var specNode = new Specification()
            {
                id = Guid.NewGuid().ToString()
            };

            theRequest = new SpecExecutionRequest(specNode, new NulloResultObserver());

            theRequest.CreatePlan(TestingContext.Library);

            theQueue = MockFor <IConsumingQueue>();

            theException = new DivideByZeroException("Wrong!");

            MockFor <ISystem>().Stub(x => x.CreateContext()).Throw(theException);

            ClassUnderTest.Status.ShouldBe(SpecRunnerStatus.Valid);

            theResults = ClassUnderTest.Execute(theRequest, theQueue);
        }
Beispiel #9
0
 public void AfterRunning(SpecExecutionRequest request, SpecResults results, IConsumingQueue queue, SpecRunnerStatus status)
 {
 }
 public void AfterRunning(SpecExecutionRequest request, SpecResults results, IConsumingQueue queue, SpecRunnerStatus status)
 {
     
 }