Create a Maven project for JBehave
Create a Maven project for JBehave
We can create the folder structure for JBehave via maven using the jbehave-simple-archetype.
There are other archetypes as well, but lets start with this simple one for now.
Navigate to the dir [lets say, C:BDD] where you want to keep all your jbehave projects, and then enter the below in the cmd prompt to download the project via mvn
mvn archetype:generate -DarchetypeGroupId=org.jbehave -DarchetypeArtifactId=jbehave-simple-archetype -DarchetypeVersion=3.9.5 -DarchetypeRepository=https://nexus.codehaus.org/content/repositories/releases/org/jbehave/jbehave-simple-archetype/
- This can take a few minutes as it will download a bunch of stuff.
- When asked to enter a groupID, enter like - com.company.department
- When asked to enter an atifactID, enter like - jbehave
- When you are asked to define value for version just press enter as we are creating a dummy project and version for us will be 1.0-SNAPSHOT
- Let the default package be same as groupId so press Enter and confirm the details by typing �y� and then enter as seen below.
- After successful completion you will see a folder named after your artifactId in your workspace which contains a pom.xml and also src folder.
Thats it, your maven project is created.
To open the project in IntelliJ -
Select the option to import a new project from the IDE, and then specify the pom.xml for the newly created jbehave project.
On the subsequent windows, select the option to automatically download the Source and Documentation. This will automatically download all the packages that you import in your classes, as and when they are used, and will prevent package not found errors.
Ensure that the JBehave plugin is installed in IntelliJ, before importing the project.
Ensure that you select the Sources and Documentation checkboxes while importing, so that all the dependencies get downloaded.
To open the project in Eclipse -
Now cd into the folder jbehave which contains the pom.xml and then execute the following command:
mvn eclipse:eclipse
This command will make your project an eclipse project which can be opened through eclipse by adding the relevant .classpath and .project files.
You should now see a sample project with Story, Steps and Stories files created.
Thats it, you are ready to roll, just behave!