This project provides a useful base class for running JBehave test scenarios with injected steps using Spring.
1 - Add dependency.
<dependency>
<groupId>com.agilarity</groupId>
<artifactId>jbehave-spring-stories</artifactId>
<version>1.0.3</version>
</dependency>
2 - Add a Spring annotated resource class.
@Configuration
@ComponentScan("com.agilarity.examples.smoke.steps")
public class SmokeTestResources {
}
3 - Specify the resource in your test class.
public class SmokeTest extends SpringJBehaveStories {
@Override
protected String[] getSpringResources() {
return new String[] { SmokeTestResources.class.getName() };
}
}
4 - Add the @Component annotation to you steps so Spring will wire it up.
5 - Put your story files under src/test/resources, at or below the same package as your test class.
6 - Run your test class as a normal JUnit test.