Hi Mauro! Thanks for the link. I used it in order to successfully set up Spring with JBehave. Regards, Julien.
2012/10/2 Mauro Talevi <[email protected]> > Hi Julien, > > nothing in BDD mandates use of DI. The autowiring of dependencies using > DI is a good practice, but it needs to make sense for you and your team > (i.e. not introduce unnecessary levels of complexity). > > Example to use Spring with Selenium and Java is found in the tutorial: > > > https://github.com/jbehave/jbehave-tutorial/tree/master/etsy-selenium/java-spring > > Cheers > > > On 02/10/2012 09:18, Julien Martin wrote: > > Hello, > > I am new to JBehave and BDD. I would like to know whether it is right > (from a BDD point of view) for steps to interact with the database via a > dao/repository. > > If that is the case, how can I alter the configuration below so that I can > inject/autowire Spring dependencies into my steps? > > Regards, > > Julien. > > Configuration is show below: > > *public class KadjoukorWebStories extends JUnitStories { > > private WebDriverProvider driverProvider = new > PropertyWebDriverProvider(); > private WebDriverSteps lifecycleSteps = new > PerStoriesWebDriverSteps(driverProvider); // or > > // PerStoryWebDriverSteps(driverProvider) > private Pages pages = new Pages(driverProvider); > private SeleniumContext context = new SeleniumContext(); > private ContextView contextView = new > LocalFrameContextView().sized(500, 100); > > public KadjoukorWebStories() { > // If configuring lifecycle per-stories, you need to ensure that > you a > // same-thread executor > if (lifecycleSteps instanceof PerStoriesWebDriverSteps) { > > configuredEmbedder().useExecutorService(MoreExecutors.sameThreadExecutor()); > } > } > > @Override > public Configuration configuration() { > Class<? extends Embeddable> embeddableClass = this.getClass(); > return new SeleniumConfiguration() > .useSeleniumContext(context) > .useWebDriverProvider(driverProvider) > .useStepMonitor(new SeleniumStepMonitor(contextView, > context, new SilentStepMonitor())) > .useStoryLoader(new LoadFromClasspath(embeddableClass)) > .useStoryReporterBuilder( > new > StoryReporterBuilder().withCodeLocation(codeLocationFromClass(embeddableClass)).withDefaultFormats() > .withFormats(CONSOLE, TXT, HTML, XML)); > } > > @Override > public InjectableStepsFactory stepsFactory() { > Configuration configuration = configuration(); > return new InstanceStepsFactory(configuration, new > KadjoukorWebSteps(pages), lifecycleSteps, new > WebDriverScreenshotOnFailure(driverProvider, > configuration.storyReporterBuilder())); > } > > @Override > protected List<String> storyPaths() { > return new > StoryFinder().findPaths(codeLocationFromClass(this.getClass()).getFile(), > asList("**/*.story"), null); > } > > // This Embedder is used by Maven or Ant and it will override anything > set > // in the constructor > public static class SameThreadEmbedder extends Embedder { > public SameThreadEmbedder() { > useExecutorService(MoreExecutors.sameThreadExecutor()); > } > } > }* > > >
