private static void TryResolve <T>(Pickle pickle, PickleStep step, IStepResolver resolver, T context) { try { resolver.Resolve(step, context); } catch (Exception e) { var plocs = String.Join(",", pickle.Locations.Select(loc => $"{loc.Line}:{loc.Column}")); var slocs = String.Join(",", step.Locations.Select(loc => $"{loc.Line}:{loc.Column}")); var message = $@" Scenario: ({plocs}) {pickle.Name} Step: ({slocs}) {step.Text} Error: {(e.InnerException ?? e).Message} Test Trace: {(e.InnerException ?? e).StackTrace} "; throw new Exception(message); } }
/// <summary> /// Executes a scenario passing the given context to each step. /// </summary> public static Outcome <T> Execute <T>(this Scenario scenario, T context, IStepResolver resolver) where T : class { scenario.Pickle.Steps .Iterate(step => TryResolve(scenario.Pickle, step, resolver, context)) .EvaluateAndIgnore(); return(Outcome.Create(context, scenario)); }