无法在JBehave中执行元过滤器

时间:2018-06-28 14:24:26

标签: jbehave

我的JUnitRunner无法通过JBehave中指定的meta标签选择方案。

以下是我的故事:

Meta:
**@TestType Smoke**
Scenario: Verify Successful login flow
Given Init my scenario for <ScenarioName>
Given I successfully launch the application
When user enters <validusername> and <validpassword> and click on Login button
Then user is navigated to Home page
Then verify entered username should be displayed
Then I logout from the application
Then Complete Tear Down

Examples:
|ScenarioName|validusername|validpassword|
|Successful Login to Chiron|abcde|12345|


Scenario: Verify Failed login flow
Given Init my scenario for <ScenarioName>
Given I successfully launch the application
When user enters <invalidusername> and <invalidpassword> and click on Login button
Then user should be in Login page itself
Then Complete Tear Down

Examples:
|ScenarioName|invalidusername|invalidpassword|
|Verify Failed login|abcdefg|ijklmn|

以下是我的跑步者文件:

public class JUnitRunnerWithTags extends JUnitStoryMaps {

    public JUnitRunnerWithTags() {
        configuredEmbedder().useMetaFilters(metaFilters());
    }

    @Override
    public Configuration configuration() {
        return new MostUsefulConfiguration()
            .useStoryReporterBuilder(new StoryReporterBuilder()
                .withCodeLocation(CodeLocations.codeLocationFromClass(this.getClass())));
    }

    @Override
    protected List<String> metaFilters() {
        return Arrays.asList("**+TestType Smoke**");
    }

    @Override
    protected List<String> storyPaths() {
        return new StoryFinder().findPaths(CodeLocations.codeLocationFromClass(this.getClass()), "**/LoginToApplication.story", "");

    }

    @Override
    public InjectableStepsFactory stepsFactory() {
        return new InstanceStepsFactory(configuration(),
                new HomePageSteps(),
                new DashboardSteps()
        );
    }

    @Test
    public void run() throws Throwable {
        super.run();
    }

}

当我将上述类作为JUnit测试运行时,带有Smoke标签的实际测试没有被调用,并且没有任何执行。

以下是我执行上述代码时得到的内容

Using controls EmbedderControls[batch=false,skip=false,generateViewAfterStories=true,ignoreFailureInStories=false,ignoreFailureInView=false,verboseFailures=false,verboseFiltering=false,storyTimeouts=300,threads=1,failOnStoryTimeout=false]
Processing system properties {}
Mapping story stories/functionaltest/login/LoginToApplication.story with meta filters [+TestType Smoke]
Generating maps view to 'D:\Cigniti\Work\Projects\automation\target\jbehave' using story maps 'StoryMaps[metaFilters=[, +TestType Smoke]]' and view properties '{navigator=ftl/jbehave-navigator.ftl, views=ftl/jbehave-views.ftl, reports=ftl/jbehave-reports.ftl, nonDecorated=ftl/jbehave-report-non-decorated.ftl, decorated=ftl/jbehave-report-decorated.ftl, maps=ftl/jbehave-maps.ftl}

1 个答案:

答案 0 :(得分:1)

您应该扩展User(而不是JUnitStories)来运行故事:

JUnitStoryMaps

更多详细信息: