Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JBehave - run a single scenario

Tags:

java

jbehave

My situation is this:

I have a JBehave story containing multiple Scenarios. Each scenario writes some files, checks that they're as expected. Then the @BeforeScenario for the next scenario causes the framework to delete the output files.

When some scenario is failing, I want to run just that scenario in isolation -- so I can conveniently examine the output file before it is deleted (and also for speed). Other people have asked the same question, and have been told "use Meta Filtering" - http://jbehave.org/reference/stable/meta-filtering.html - which seems to be the right tool.

But I don't want to go to the effort of annotating every other scenario with @skip. I'd like to annotate just one scenario with @wip, and run just that test.

I tried this:

Narrative:
An example story

Scenario: A scenario I don't want to run this time
Given foo
When bar
Then baz

Meta: @wip
Scenario: A scenario that is work in progress
Given foo
When bar
Then baz

... which I then run with an Embedder configured thus:

embedder.useMetaFilters(Arrays.asList("+wip"));

This causes the whole story to be skipped, because the story doesn't match:

1 stories excluded by filter: +wip

However, if I annotate the story with @wip, then both scenarios are run, because both inherit the wip meta property.

Is there a neat way to achieve this?

like image 788
slim Avatar asked Oct 15 '15 10:10

slim


1 Answers

The issue is simply that your Meta: declaration belongs below the Scenario: header.

So:

Scenario: A scenario that is work in progress
Meta: @wip
Given foo
When bar
Then baz

Now embedder.useMetaFilters(Arrays.asList("+wip")); will achieve what you want.

like image 85
slim Avatar answered Nov 02 '22 06:11

slim