{"id":20678,"date":"2017-09-10T14:00:22","date_gmt":"2017-09-10T14:00:22","guid":{"rendered":"https:\/\/www.testingdocs.com\/questions\/?p=20678"},"modified":"2024-12-14T16:43:39","modified_gmt":"2024-12-14T16:43:39","slug":"how-to-run-multiple-stories-in-jbehave-automation-project","status":"publish","type":"post","link":"https:\/\/www.testingdocs.com\/questions\/how-to-run-multiple-stories-in-jbehave-automation-project\/","title":{"rendered":"How to run Multiple Stories in JBehave automation project?"},"content":{"rendered":"<h1>How to run Multiple Stories in JBehave automation project?<\/h1>\n<p>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&#8217;s see how to run using Maven build tool.<\/p>\n<h3>JBehave Stories<\/h3>\n<p>Define JBehave stories for the automation project with Gherkin or similar DSL syntax. Add Step definitions java code for the stories.<\/p>\n<p><a href=\"https:\/\/www.testingdocs.com\/writing-simple-jbehave-story\/\">https:\/\/www.testingdocs.com\/writing-simple-jbehave-story\/<\/a><\/p>\n<h2>Code perspective<\/h2>\n<p>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:<\/p>\n<p>public class TestingDocsComStories extends JUnitStories {<\/p>\n<p>&#8230;<\/p>\n<p>}<\/p>\n<p>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.<\/p>\n<p>More Information:<\/p>\n<p><a href=\"https:\/\/www.testingdocs.com\/running-jbehave-stories-junitstory-and-junitstories\/\">https:\/\/www.testingdocs.com\/running-jbehave-stories-junitstory-and-junitstories\/<\/a><\/p>\n<h2>Build Perspective<\/h2>\n<p>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.<\/p>\n<p><strong>Embedder<\/strong> 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.<\/p>\n<div class=\"line number26 index25 alt1\"><code class=\"\" data-line=\"\">&lt;<\/code><code class=\"\" data-line=\"\">goals<\/code><code class=\"\" data-line=\"\">&gt;<\/code><\/div>\n<div class=\"line number27 index26 alt2\"><code class=\"\" data-line=\"\">\u00a0 \u00a0 <\/code><code class=\"\" data-line=\"\">&lt;<\/code><code class=\"\" data-line=\"\">goal<\/code><code class=\"\" data-line=\"\">&gt;run-stories-as-embeddables&lt;\/<\/code><code class=\"\" data-line=\"\">goal<\/code><code class=\"\" data-line=\"\">&gt;<\/code><\/div>\n<div class=\"line number28 index27 alt1\"><code class=\"\" data-line=\"\">&lt;\/<\/code><code class=\"\" data-line=\"\">goals<\/code><code class=\"\" data-line=\"\">&gt;<\/code><\/div>\n<p>&nbsp;<\/p>\n<h3>On Linux<\/h3>\n<p>cd to the pom.xml file location and issue the following Linux terminal command:<\/p>\n<p><strong>$ mvn clean install<\/strong><\/p>\n<p>or the goal defined in the pom.xml. If the goal defined is &#8216;integration-test&#8217;. This is specify to running tests.<\/p>\n<p><strong>$ mvn integration-test<\/strong><\/p>\n<h3>On Windows<\/h3>\n<p>Launch command prompt, cd to the pom.xml file and issue the command at the prompt:<\/p>\n<p><strong>\/&gt; mvn clean install<\/strong><\/p>\n<p>&nbsp;<\/p>\n<h3>From IDE<\/h3>\n<p>On Eclipse IDE we can run the JBehave stories by right click on the project <strong>Run As &gt;&gt; Maven build<\/strong>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-20689\" src=\"https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Run-multiple-stories-JBehave.png\" alt=\"Run multiple stories JBehave\" width=\"1569\" height=\"1009\" title=\"\" srcset=\"https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Run-multiple-stories-JBehave.png 1569w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Run-multiple-stories-JBehave-300x193.png 300w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Run-multiple-stories-JBehave-1024x659.png 1024w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Run-multiple-stories-JBehave-768x494.png 768w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Run-multiple-stories-JBehave-1536x988.png 1536w\" sizes=\"auto, (max-width: 1569px) 100vw, 1569px\" \/><\/p>\n<p>&nbsp;<\/p>\n<h3>JBehave Tutorials<\/h3>\n<p>JBehave Tutorials on this website can be found at:<br \/>\n<strong><a href=\"https:\/\/www.testingdocs.com\/jbehave-framework-tutorial\/\">https:\/\/www.testingdocs.com\/jbehave-framework-tutorial\/<\/a><\/strong><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[250],"tags":[],"class_list":["post-20678","post","type-post","status-publish","format-standard","hentry","category-jbehave","has-post-title","has-post-date","has-post-category","has-post-tag","has-post-comment","has-post-author",""],"_links":{"self":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/20678","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/comments?post=20678"}],"version-history":[{"count":28,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/20678\/revisions"}],"predecessor-version":[{"id":26480,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/20678\/revisions\/26480"}],"wp:attachment":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/media?parent=20678"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/categories?post=20678"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/tags?post=20678"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}