public void stops_with_a_critical_exception_even_if_there_is_no_other_failure() { theContext.StopConditions.BreakOnExceptions = false; theContext.LogException("1", new StorytellerCriticalException()); theContext.CanContinue().ShouldBe(false); }
public void Execute(SpecContext context) { var record = context.Timings.Subject(Type, Subject, maximumRuntimeInMilliseconds); Values.DoDelayedConversions(context); StepResult result = null; if (Values.Errors.Any()) { result = Values.ToConversionErrorResult(); result.position = Position; context.LogResult(result, record); return; } try { result = IsAsync() ? executeAsync(context).GetAwaiter().GetResult() : execute(context); result.position = Position; context.LogResult(result, record); } catch (Exception ex) { context.LogException(Values.id, ex, record, Position); } }
public void Execute(SpecContext context) { // TODO -- add threshold here? var record = context.Timings.Subject(type, Subject, 0); try { Action(context); var result = new StepResult(Id, ResultStatus.ok) { position = Position }; context.LogResult(result, record); context.Timings.End(record, result); } catch (Exception ex) { context.LogException(Node.id, ex, record, Position); context.Timings.End(record); } }
public void Execute(SpecContext context) { using (context.Timings.Subject(Type, Subject)) { Values.DoDelayedConversions(context); if (Values.Errors.Any()) { var result = Values.ToConversionErrorResult(); result.position = Position; context.LogResult(result); return; } try { var result = execute(context); result.position = Position; context.LogResult(result); } catch (Exception ex) { context.LogException(Values.id, ex, Position); } } }
public StepthroughExecutor(IExecutionContext execution, SpecExecutionRequest request, IUserInterfaceObserver observer) { _context = new SpecContext(request.Specification, new Timings(), request.Observer, new StopConditions(), execution); _execution = execution; _request = request; _observer = observer; var gatherer = new ExecutionStepGatherer(_context); _request.Plan.AcceptVisitor(gatherer); _steps = gatherer.Lines; try { _execution.BeforeExecution(_context); } catch (Exception e) { _context.LogException(_request.Id, e, "BeforeExecution"); } _observer.SendProgress(new SpecProgress(_request.Id, _context.Counts, 0, _steps.Count)); sendNextStepMessage(); }
public Task ExecuteAsync(SpecContext context, CancellationToken cancellation) { var record = context.Timings.Subject("Grammar", _grammar.Key, _maximumRuntimeInMilliseconds); var fetch = _comparison.Fetch(context); if (!convertData(context, record)) { return(Task.CompletedTask); } return(fetch.ContinueWith(t => { if (t.IsFaulted) { // TODO -- do the Flatten() trick here on the aggregated exception context.LogException(_section.id, t.Exception, record, Stage.before); return; } if (t.IsCompleted) { var result = CreateResults(_expected, t.Result); result.id = _section.id; context.LogResult(result, record); context.Timings.End(record, result); } }, cancellation)); }
public async Task ExecuteAsync(SpecContext context, CancellationToken cancellation) { if (AsyncAction != null) { // TODO -- add threshold here? var record = context.Timings.Subject(type, Subject, 0); try { await AsyncAction(context); var result = new StepResult(Id, ResultStatus.ok) { position = Position }; context.LogResult(result, record); context.Timings.End(record, result); } catch (Exception ex) { context.LogException(Node.id, ex, record, Position); context.Timings.End(record); } } else { Execute(context); } }
public void Execute(SpecContext context) { // TODO -- add threshold here? var record = context.Timings.Subject(type, Subject, 0); try { if (AsyncAction != null) { AsyncAction(context).Wait(context.StopConditions.TimeoutInSeconds.Seconds()); } else { Action(context); } var result = new StepResult(Id, ResultStatus.ok) { position = Position }; context.LogResult(result, record); context.Timings.End(record, result); } catch (Exception ex) { context.LogException(Node.id, ex, record, Position); context.Timings.End(record); } }
private void beforeExecution(IExecutionContext execution, SpecContext context) { try { execution.BeforeExecution(context); } catch (Exception e) { context.LogException(Request.Id, e, null, "BeforeExecution"); } }
public void Execute(SpecContext context) { using (context.Timings.Subject(_type, Subject)) try { _action(context); } catch (Exception ex) { context.LogException(_node.id, ex, Position); } }
public void Execute(SpecContext context) { using (context.Timings.Subject(type, Subject)) try { Action(context); context.LogResult(new StepResult(Id, ResultStatus.ok) {position = Position}); } catch (Exception ex) { context.LogException(Node.id, ex, Position); } }
public void log_exception_captures_it_in_the_Exceptions_report() { var ex = new NotImplementedException("No go"); theContext.Reporting.ReporterFor <ExceptionReport>().Count.ShouldBe(0); theContext.LogException("1", ex); theContext.Reporting.ReporterFor <ExceptionReport>().Count.ShouldBe(1); theContext.Reporting.ReporterFor <ExceptionReport>().ToHtml().ShouldContain("No go"); }
// If this fails, it's a catastrophic exception public SpecResults Execute(ISystem system, Timings timings) { _timeout = setupTimeout(); using (var execution = createExecutionContext(system, timings)) { if (Request.IsCancelled) { return(null); } using (var context = new SpecContext( Request.Specification, timings, Request.Observer, StopConditions, execution)) { if (Request.Specification.HasNoSteps()) { context.LogException(Request.Specification.id, new NotImplementedException("Empty specification with no implementation"), null, Stage.context); } beforeExecution(execution, context); var lines = determineLineSteps(context); startDebugListening(context); Logger.Starting(lines); if (lines.Any()) { var stepRunning = executeSteps(context, lines, Request.Cancellation); Task.WaitAny(stepRunning, _timeout); } execution.AfterExecution(context); return(buildResults(context, timings)); } } }
public void Execute(SpecContext context) { using (context.Timings.Subject(_type, Subject)) try { _action(context); context.LogResult(new StepResult(Id, ResultStatus.ok) { position = Position }); } catch (Exception ex) { context.LogException(_node.id, ex, Position); } }
private void execute() { try { using (_timings.Subject("Context", "Creation")) { _execution = _system.CreateContext(); } } catch (Exception e) { _catastrophicException = e; _reset.Set(); return; } if (_request.IsCancelled) { return; } _context = new SpecContext(_request.Specification, _timings, _request.Observer, _stopConditions, _execution); try { _execution.BeforeExecution(_context); } catch (Exception e) { _context.LogException(_request.Id, e, "BeforeExecution"); } _context.Reporting.As <Reporting>().StartDebugListening(); var executor = _mode.BuildExecutor(_request.Plan, _context); _request.Plan.AcceptVisitor(executor); _execution.AfterExecution(_context); _reset.Set(); }
public void Execute(SpecContext context) { using (context.Timings.Subject("Grammar", _section.Key)) { var fetch = _comparison.Fetch(context); _expected.Each(x => { x.DoDelayedConversions(context); if (!x.Errors.Any()) { return; } context.LogResult(x.ToConversionErrorResult()); }); if (_expected.Any(x => x.HasErrors())) { return; } fetch.ContinueWith(t => { if (t.IsFaulted) { // TODO -- do the Flatten() trick here on the aggregated exception context.LogException(_section.id, t.Exception, Stage.before); return; } if (t.IsCompleted) { var result = CreateResults(_expected, t.Result); result.id = _section.id; context.LogResult(result); } }).Wait(); } }
public void Execute(SpecContext context) { using (context.Timings.Subject("Grammar", _section.Key)) { var fetch = _comparison.Fetch(context); _expected.Each(x => { x.DoDelayedConversions(context); if (!x.Errors.Any()) return; context.LogResult(x.ToConversionErrorResult()); }); if (_expected.Any(x => x.HasErrors())) return; fetch.ContinueWith(t => { if (t.IsFaulted) { // TODO -- do the Flatten() trick here on the aggregated exception context.LogException(_section.id, t.Exception, Stage.before); return; } if (t.IsCompleted) { var result = CreateResults(_expected, t.Result); result.id = _section.id; context.LogResult(result); } }).Wait(); } }
public Task ExecuteAsync(SpecContext context, CancellationToken cancellation) { if (!IsAsync()) { return(Task.Factory.StartNew(() => Execute(context), cancellation)); } var record = context.Timings.Subject(Type, Subject, maximumRuntimeInMilliseconds); return(executeAsync(context).ContinueWith(t => { if (t.IsFaulted) { context.LogException(Values.id, t.Exception, record, Position); } else { var result = t.Result; result.position = Position; context.LogResult(result, record); } }, cancellation)); }
private void beforeExecution(IExecutionContext execution, SpecContext context) { try { execution.BeforeExecution(context); } catch (Exception e) { context.LogException(Request.Id, e, "BeforeExecution"); } }
private void execute(EventWaitHandle reset) { try { using (_timings.Subject("Context", "Creation")) { _execution = _system.CreateContext(); } } catch (Exception e) { _catastrophicException = e; reset.Set(); return; } if (_request.IsCancelled) return; _context = new SpecContext(_request.Specification, _timings, _request.Observer, _stopConditions, _execution); try { _execution.BeforeExecution(_context); } catch (Exception e) { _context.LogException(_request.Id, e, "BeforeExecution"); } _context.Reporting.As<Reporting>().StartDebugListening(); var executor = _mode.BuildExecutor(_request.Plan, _context); _request.Plan.AcceptVisitor(executor); _execution.AfterExecution(_context); reset.Set(); }