5

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?

slim
  • 40,215
  • 13
  • 94
  • 127
  • 1
    I have [scenario filtering](http://jbehave.org/reference/stable/meta-filtering.html) working by matching on scenario tags and filtering on the value. e.g. "Meta: @scenario wip" and embedder.useMetaFilters(Arrays.asList("+scenario wip")). But before you try custom tag-values, you should switch the order of your Scenario and Meta tags to follow jBehave grammar – Chrizt0f Oct 19 '15 at 20:58
  • That could well be it! – slim Oct 20 '15 at 10:11
  • 1
    Yep. Tried it out, and your comment became my answer. – slim Oct 20 '15 at 12:11

1 Answers1

6

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.

slim
  • 40,215
  • 13
  • 94
  • 127