JBehave working with Maven
Okay it took a fair bit of digging, but after [failing to get JBehave to work on the first attempt](http://blog.frontierfrenzy.com/post/43309958290/bdd-with-jbehave), I managed to stumble on something that works. Conclusion, JBehave is NOT straightforward to include in your project! I needed to make changes to the pom.xml and completely replace the PlayerStory class with a PlayerStories class **pom.xml** 4.0.0 modelVersion> com.frontierfrenzy game artifactId> 0.0.1 version> UTF-8 project.build.sourceEncoding> UTF-8 project.reporting.outputEncoding> 3.7.5 jbehave.version> 4.11 junit.version> de.codecentric jbehave-junit-runner artifactId> 1.0.1 version> junit junit ${junit.version} org.jbehave jbehave-core ${jbehave.version} org.apache.maven.plugins maven-compiler-plugin 2.3.2 version> 1.7 source> 1.7 target> org.jbehave jbehave-maven-plugin ${jbehave.version} run-stories-as-embeddables integration-test test scope> **/*Stories.java java.awt.headless true value> true ignoreFailureInStories> false ignoreFailureInView> run-stories-as-embeddables **\src\test\java\com\frontierfrenzy\model\test\PlayerStories.java:** package com.frontierfrenzy.model.test; import java.util.List; import org.jbehave.core.configuration.Configuration; import org.jbehave.core.configuration.MostUsefulConfiguration; import org.jbehave.core.io.CodeLocations; import org.jbehave.core.io.LoadFromClasspath; import org.jbehave.core.io.StoryFinder; import org.jbehave.core.junit.JUnitStories; import org.jbehave.core.reporters.Format; import org.jbehave.core.reporters.StoryReporterBuilder; import org.jbehave.core.steps.InjectableStepsFactory; import org.jbehave.core.steps.InstanceStepsFactory; import org.junit.runner.RunWith; import de.codecentric.jbehave.junit.monitoring.JUnitReportingRunner; @RunWith(JUnitReportingRunner.class) public class PlayerStories extends JUnitStories { @Override protected List storyPaths() { return new StoryFinder().findPaths(CodeLocations.codeLocationFromPath( "src/test/resources"), "**/*.story", "**/exclude_*.story"); } @Override public Configuration configuration() { return new MostUsefulConfiguration() .useStoryLoader( new LoadFromClasspath(this.getClass())) .useStoryReporterBuilder( new StoryReporterBuilder() .withFormats(Format. XML, Format.IDE_CONSOLE , Format.CONSOLE, Format.HTML, Format.TXT )); } @Override public InjectableStepsFactory stepsFactory() { return new InstanceStepsFactory(configuration(), new PlayerSteps()); } } Heres is my project layout so far: \src\main \src\test \src\main\java \src\main\resources \src\main\java\com \src\main\java\com\frontierfrenzy \src\main\java\com\frontierfrenzy\model \src\main\java\com\frontierfrenzy\model\Account.java \src\main\java\com\frontierfrenzy\model\Player.java \src\test\java \src\test\resources \src\test\java\com \src\test\java\com\frontierfrenzy \src\test\java\com\frontierfrenzy\model \src\test\java\com\frontierfrenzy\model\test \src\test\java\com\frontierfrenzy\model\test\PlayerSteps.java \src\test\java\com\frontierfrenzy\model\test\PlayerStories.java \src\test\resources\player.story Now when I run mvn verify I get this in the output (BeforeStories) [INFO] Running story player.story Story: Player can create a new account (player.story) Scenario: Story: Player can create a new account Narrative: As a player I want to be able to create a new player account So I can play the game Scenario 1: Given a player with email address [email protected] When he creates an account Then a new account is created (FAILED) (java.lang.AssertionError: ) (AfterStories)














