In this post, we will discuss writing JBehave automation story. A story file is usually stored within a “.story” extension file. Also, it is usually called a story file. An automation jbehave story has 5 main components. ( although it might contain other parts like Examples table etc.)
2. Meta: Meta information is mostly used to categorize the stories.
3. Narrative: Narrative is the description of the story i.e user story business description. The business flow consists of per-conditions, user actions, and expectations.
4. Scenario: A scenario is a collection of executable steps. A brief description of the scenario usually one-liner goes here. Also, a story can have multiple scenarios. Furthermore, steps are described below.
5. Steps: Steps are a user-based implementation of the story.
Given step represents a precondition to an event
When step represents the occurrence of the event
Then step represents the outcome of the event
Sample automation story
To validate the ADD functionality of Calculator
Meta: @Regression @Automated Narrative: As a Calculator user I want to add 2 integers with the add button So, that I can verify the sum of added numbers Add functionality Scenario: A user adds 2 integers and verifies the sum Given I am a Calculator user And I have two integer numbers to add When I add the numbers with the plus button Then I verify the sum of the two numbers
In conclusion, the stories contain references to the step java methods. Also, when you control-click on the text step the corresponding matched step method would be launched. Furthermore, it is always recommended to update the story file from within the IDE editor, so that you don’t miss out on any errors.
As the number of automation stories increases in number, it must be important to maintain some kind off hierarchy and group similar tests within the same hierarchy. This makes debugging and story management easy.