Filtrado con múltiples metafiltros en JBehave

Situación:

In my current project we are running all kinds of different JBehave stories. Every ".story" file is related to a product and a flow.

Ejemplo:
xyz-cellphone-call.story would be the story describing making a phonecall with a cellphone.
xyz-phone-call.story would be the story describing making a phonecall with a fixed-line phone.
xyz-cellphone-browse.story would be the story describing browsing the internet with a cellphone.

Mi pregunta es: In Jbehave you can add metaFilters to filter on the stories based on meta tags. Assume the tags are @product & @action. (@product cellphone, @action call).
Would it be possible to pass a filter to run the JBehave stories concerning both the phone & cellphone stories, if yes, what would be the syntax?

I've tried adding the following filters (none of which work):

+product cellphone +product phone
+product cellphone|phone
+product cellphone,phone

Same for actions.

Is it possible to filter on multiple meta-tags?

preguntado el 31 de julio de 12 a las 15:07

3 Respuestas

Yes it is possible. In the API docs you will find this information:

A filter is uniquely identified by its String representation which is parsed and matched by the MetaFilter.MetaMatcher to determine if the Meta is allowed or not.

The MetaFilter.DefaultMetaMatcher interprets the filter as a sequence of any name-value properties (separated by a space), prefixed by "+" for inclusion and "-" for exclusion. E.g.:

MetaFilter filter = new MetaFilter("+author Mauro -theme smoke testing +map *API -skip"); filter.allow(new Meta(asList("map someAPI")));

The use of the MetaFilter.GroovyMetaMatcher is triggered by the prefix "groovy:" and allows the filter to be interpreted as a Groovy expression.

MetaFilter filter = new MetaFilter("groovy: (a == '11' | a == '22') && b == '33'");

So probably if you play with the conditions, you will get your run configuration customized. Try this example:

mvn clean install -P -Djbehave.meta.filter="myCustomRunConf:(+product && +action)"

More info amout the MetaFilter class in the API docs: http://jbehave.org/reference/stable/javadoc/core/org/jbehave/core/embedder/MetaFilter.html

Respondido 23 Oct 12, 20:10

Okay, I will have to retry this, but in the past I have tried the filter "+product phone +action call" and it did not work. - HPacquee

@HPacquee I updated the answer, I think now is more accurate. - javándose

I guess there is easier solution for you using groovy http://jbehave.org/reference/stable/meta-filtering.html

In your case it would be -Dmetafilter="groovy: "product=='cellphone' && action=='call'"

I tried it as "-Dmetafilter=groovy:t2 && t3" for this feature file

Meta:
    @t1

Narrative:
    As a user
    I want to blah-blah-blah


Scenario: test 1
Meta:
    @t2

Given I am on home page


Scenario: test 2
Meta:
    @t2
    @t3

Given I am on home page


Scenario: test 3
Meta:
    @t3

Given I am on home page

Only test 2 scenario is executed in this case

Respondido 24 ago 15, 15:08

Qué tal si:

mvn clean install -P -Djbehave.meta.filter = "+product cellphone&&phone"

respondido 03 nov., 17:16

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.