JBehave - serial execution across GivenStories

1k Views Asked by At

I am using JBehave - I have three stories - third story refers other two stories:

GivenStories Story1, Story2

Given Some_Thing When you_compare_output_of_story_1_to_output_of_story_2 Then verify_the_result

When I run this third story - expectation is to run the

first scenario of 1st story first scenario of 2nd story then the scenario in 3rd story

--

second scenario of 1st story second scenario of 2nd story then the scenario in 3rd story

but JBehave runs all the scenarios in the 1st story, then all the scenarios in the 2nd story ..:(

I am not finding a way to get it the way I am looking for. Can someone help?

2

There are 2 best solutions below

3
On

Read about GivenStories filtered by scenario meta parameters

The idea is that you use meta tags in the first and second stories, like in below examples:

First story

First story

Scenario: scenario 1
Meta: @id1 scenario1

Given Story 1 scenario 1
..........


Scenario: scenario 2
Meta: @id1 scenario2

Given Story 1 scenario 2
..........

Scenario: scenario 3
Meta: @id1 scenario3

Given Story 1 scenario 3
..........



Second story

Second story

Scenario: scenario 1
Meta: @id1 scenario1

Given Story 2 scenario 1
..........


Scenario: scenario 2
Meta: @id1 scenario2

Given Story 2 scenario 2
..........

Scenario: scenario 3
Meta: @id1 scenario3

Given Story 2 scenario 3
..........



and in the third story you need to filter them using these meta tags:

Third story

Scenario: scenario 1
GivenStories: path/to/stories/first_story.story#{id1:scenario1},
              path/to/stories/second_story.story#{id1:scenario1}

Given Story 3 scenario 1
..........

Scenario: scenario 2
GivenStories: path/to/stories/first_story.story#{id1:scenario2},
              path/to/stories/second_story.story#{id1:scenario2}

Given Story 3 scenario 2
..........


Scenario: scenario 3
GivenStories: path/to/stories/first_story.story#{id1:scenario3},
              path/to/stories/second_story.story#{id1:scenario3}

Given Story 3 scenario 3
..........
0
On

Try using jbehave version 4.3 which has fix provided