Default

How to run Multiple Stories in JBehave automation project?

How to run Multiple Stories in JBehave automation project?

In this tutorial, we will learn how to run multiple stories in a JBehave automation project. There are multiple ways to run the JBehave stories for a project. The process to run stories depends on the build tool used in the project. JBehave has excellent Maven build tool integration. So. let’s see how to run using Maven build tool.

JBehave Stories

Define JBehave stories for the automation project with Gherkin or similar DSL syntax. Add Step definitions java code for the stories.

https://www.testingdocs.com/writing-simple-jbehave-story/

Code perspective

We need to define an entry-point class for the JBehave framework to run the stories in the automation project. For example, entry could be something like:

public class TestingDocsComStories extends JUnitStories {

…

}

This class should define all the configuration logistics for the project. Things like defining the Steps factory , story filters and should be define the story paths to find the stories.

More Information:

https://www.testingdocs.com/running-jbehave-stories-junitstory-and-junitstories/

Build Perspective

JBehave Maven plugin is capable and will run the stories in the project. Maven goal something like test or integration-test should be defined in the POM.xml file to run the stories. For example, running Maven goals from the command line should run all the stories in the automation project.

Embedder is the entry point for running stories in JBehave. A Maven plugin can be used to set the phase and the goal can be set in the pom.xml file.

<goals>
    <goal>run-stories-as-embeddables</goal>
</goals>

 

On Linux

cd to the pom.xml file location and issue the following Linux terminal command:

$ mvn clean install

or the goal defined in the pom.xml. If the goal defined is ‘integration-test’. This is specify to running tests.

$ mvn integration-test

On Windows

Launch command prompt, cd to the pom.xml file and issue the command at the prompt:

/> mvn clean install

 

From IDE

On Eclipse IDE we can run the JBehave stories by right click on the project Run As >> Maven build.

Run multiple stories JBehave

 

JBehave Tutorials

JBehave Tutorials on this website can be found at:
https://www.testingdocs.com/jbehave-framework-tutorial/