黄瓜场景概述与示例:无法创建场景运行器

时间:2015-06-09 20:02:54

标签: java testing junit cucumber

我开始从事测试自动化工作,目前我遇到了一个小问题。

我制作了Gherkin场景:

Feature: Post Draft

  Scenario: Successful Login with Valid Credentials
    Given User go to Admin Page
    Then User enters UserName and Password

  Scenario Outline: Successful creation post draft
    Given User navigate to pages list
    Then User open page with ID <postsIds> for editing
    Then User navigate to Advertising tab
    Then User check custom ads code radio button
    And Insert custom advertising code
    Then User save post
    And See that custom ads code is appears

    Examples:
      | postsIds |
      | 61591    |
      | 62231    |
      | 61827    |
      | 63300    |
      | 62023    |
      | 62231    |

当我尝试执行这个场景时,我遇到了错误:

cucumber.runtime.CucumberException: Failed to create scenario runner
    ... 21 more

有人有同样的问题吗?我不知道是什么问题,因为如果我删除Outline关键字和例子列表,测试正在运行......

我实现了所有步骤,它没有大纲,但我有很多值,我不想为每个值实现步骤,这就是为什么我需要使用场景大纲

请帮我解决这个问题。

1 个答案:

答案 0 :(得分:3)

我发现了问题。我将cucumber-junit软件包更新到了​​最新版本,它没有向后兼容性。

以下是Maven依赖项,有效:

<dependencies>
    <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>cucumber-picocontainer</artifactId>
        <version>1.1.8</version>
    </dependency>
    <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>cucumber-junit</artifactId>
        <version>1.1.8</version>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.11</version>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-server</artifactId>
        <version>2.42.2</version>
    </dependency>
</dependencies>

GHERKIN: SCENARIO OUTLINES

我还有一篇文章Cucumber testing guide