In this post, we will learn how to filter stories or scenarios during automation dry runs. In real projects, you have many stories under the project folder. It’s important to keep the stories well organized by grouping the scenarios.
When you execute the stories, you have several ways to filter the stories. The most common way to
filter stories are to use the meta filter.
Let’s say your project has hundreds of stories. Consider the fact that you have automated a scenario or story in the project. You may want to quickly run the scenario and verify your automation effort and exclude all the other stories to be executed in the project.
Add the meta filter in the story or scenario.
For example story we have to run and exclude all other stories in the project.
Lookup a definition
In order to do Mathematics better
As a Maths student
I want to look up math word definitions
Scenario: Looking up the definition of ‘cosine’
Given the user is on the Wikionary home page
When the user looks up the definition of the word ‘cosine’
Then they should see the definition ‘In a right triangle, the ratio of the length of the side adjacent to an acute angle to the length of the hypotenuse.’
@dryrun is a sample filter. You can pick any filter of your choice. It makes sense to use meaningful words if you are grouping stories. For example, @billing for all billing related stories and scenarios.
Now, add the filter to the run configuration in Eclipse to run the story.
Right click >> Run as >> Run Configuration >> Maven build
Add the goals to filter:
Click on Run.
View or verify the report for the story.
/> mvn clean verify -Dmetafilter=”+dryrun”
In this approach you save a lot of time verifying your automation results especially when you are automating new stories and scenarios. In this use case you are not interested about the other stories in the project. The main focus is your newly added automation story verification.
JBehave Tutorials on this website can be found at:
For more details on the JBehave framework, visit the official JBehave website at: