0

Is there a way we can filter jbehave examples table rows at runtime using the scenario meta data? For e.g

Scenario: my scenario title Meta:

@id 1

Examples:

|Meta:|col1|col2|
|id 1 |val1|val2|
|id 2| val |val |
|id 1| val |val |

When we run this scenario it should iterate only for the 1st and 3rd row, based on the meta data set on the scenario. What I am trying to do is to externalize data across scenarios/ stories and try to use filtered data rows applicable for particular scenario.

I found some similar topics based meta filtering but not specific to this.

Appreciate any help. Thanks

Nishant
  • 3
  • 1

1 Answers1

0

A meta character @ must be used in the example table, in this way:

Scenario: some scenario

Meta:  @id

Given I pass value '1'

Examples: 
|Meta:|col1|col2|
|@id 1|val1|val2|
|@id 2| val|val |
|@id 1| val|val |

Then you need to define the filter in the configuration, for example:

 configuredEmbedder().useMetaFilters(Arrays.asList("+id 1"));

More on this topic can be found here: http://jbehave.org/reference/stable/meta-filtering.html

krokodilko
  • 35,300
  • 7
  • 55
  • 79