Sunday, August 5, 2018

JBehave Hello World example (Eclipse + Maven + JUnit)

JBehave is a framework for Behaviour-Driven Development (BDD). To know more about JBehave, click here.

Below is the eclipse folder structure -



Please create a maven project and add the following files -


pom.xml

This contains the hello world business logic that need to be tested using JBehave
HelloWorld.java

This file contains the test cases
hello-world.story

This file contains the steps for BDD testing
HelloWorldSteps.java

This is the main test class from where we can trigger various stories for testing. Using InjectableStepsFactory you can provide list of Steps classes, in our case it is HelloWorldSteps.java.
It also provides the configuration used by the Embedder and the in the Embeddable implementations to customise its runtime properties.
Stories.java

Now compile the maven project using mvn clean build command. It show show BUILD SUCCESS message.

Now run the Stories.java (Right click on Stories.java -> Run As -> JUnit Test)

Console Output


Also you can find the JBehave repots in JBehaveHelloWorld\target\jbehave\view folder

Reports in target folder


Generated JBehave report

No comments:

Post a Comment