How to skip a particular scenario on Jbehave tests

2019-07-07 04:31发布

问题:

I have a particular scenario which is not ready for testing yet. So I need to skip it in order to run the tests on other scenarios.

Scenario: Login-success Scenario:

Meta:
@skip
@ignored true

//Regular Steps

回答1:

In order to use @skip or @ignore true meta in a story to skip this story,
you need to configure a meta filter in configuration of your test.

Depending on how you configure your test, it could be for example:

@RunWith(AnnotatedEmbedderRunner.class)
@UsingEmbedder(metaFilters = {"-skip"})
public class AnnotatedTraderEmbedder extends InjectableEmbedder {
} 

or, in Java:

public MyStories() {
    configuredEmbedder().embedderControls().doGenerateViewAfterStories(true)
        .doIgnoreFailureInStories(true)
        .doIgnoreFailureInView(true).useThreads(1); 
    // Meta filters:
    configuredEmbedder().useMetaFilters(Arrays.asList("-skip"));
}

See the documentation for details: http://jbehave.org/reference/stable/meta-filtering.html



回答2:

You can simply skip the test using the @skip in the meta info:

Scenario:  A scenario which we cannot run every time due to some technical contraint
Meta:
@skip     
@ignored true  
Given ... // normal scenario steps

Documentation on meta tags can be found here