【问题标题】:Unable to execute Meta filters in JBehave无法在 JBehave 中执行元过滤器
【发布时间】:2018-06-28 14:24:26
【问题描述】:

我的 JUnitRunner 无法使用 JBehave 中指定的元标记选择场景。

以下是我的故事:

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}

【问题讨论】:

    标签: jbehave


    【解决方案1】:

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

    public class JUnitRunnerWithTags extends JUnitStories {
    
        public JUnitRunnerWithTags() {
            configuredEmbedder().useMetaFilters(Arrays.asList("**+TestType Smoke**"));
        }
    
    ...
    

    更多详情:

    【讨论】:

    • 如链接中指定的那样,如果我们需要处理套件中的元标记,还可以观察到它们已经扩展了“JUnitStoryMaps”。
    • @Uday 第二个链接还包含元过滤器的注释示例configuredEmbedder().useMetaFilters(Arrays.asList("+theme parametrisation"));
    • 感谢 Val,正如我在帖子中所展示的那样,我的代码中已经有了。配置Embedder().useMetaFilters(metaFilters()); @Override protected List metaFilters() { return Arrays.asList("+TestType Smoke"); }
    • 不....我还没有听到任何其他解决方案。你给我的任何东西都已经在我尝试过的代码中了。
    • 您是否已将JUnitStoryMaps 替换为JUnitStories
    猜你喜欢
    • 2012-07-29
    • 1970-01-01
    • 2015-05-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多