当前位置: 首页 > 知识库问答 >
问题:

无法在JBehave中执行元筛选器

袁骏祥
2023-03-14

我的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 test运行上述类时,没有调用带有烟雾标记的实际测试,也没有执行任何内容。

下面是我在执行上面的代码时得到的结果

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个答案

慕乐池
2023-03-14

您应该扩展JUnitStories(而不是JUnitStoryMaps)以运行Stories:

public class JUnitRunnerWithTags extends JUnitStories {

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

...

更多详情如下:

  • 故事映射
  • 启用JUnit的嵌入式
 类似资料:
  • 在https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-filter-aggregation.html我们了解到: 以上代码显示了我们如何为t恤添加aggs,但我们如何做到: 和

  • 问题内容: 我正在尝试CSS过滤器,但在我的Firefox(15.0)浏览器中不起作用。 HTML: CSS: 问题答案: GrayScale具有使用-moz-filter在Firefox中运行的限制。 要使其正常工作,请使用以下代码段:

  • 我想实现这样的目标: 筛选,然后从筛选结果中更改属性,然后将结果收集到列表中。然而,调试器说: 无法对基元类型 调用 我需要2个流吗?

  • 因此,这是我第一次使用JBehave,我试图在项目中创建第一个JBehave,但目前似乎测试没有执行这些步骤。最后,测试表明所有测试用例都通过了,没有任何问题,但实际上它们根本没有被执行。我在每个步骤方法中都设置了断点,而且我的调试器根本不会阻止我,更不用说这些步骤当前抛出的异常了。 和测试执行器: 你知道有什么问题吗?

  • 我正在尝试在Spring Cloud Gateway中启用RequestRateLimiter。我havr配置了其他过滤器,甚至是自定义过滤器,但当我将其添加到我的路由中时: 我得到了这个异常(当然,如果我移除RequestRateLimiter筛选器并只保留StripPrefix条目,一切正常。我已经删除了异常的代码):