java - Cucumber - 在 java 中实现缺失的步骤

标签 java cucumber gherkin

我有以下 cucumber 功能,没有任何相应的 java 代码操作。

@CucumberTest
Scenario: Testing cucumber
 Given I have this test.
 When I test This
 Then I get this

当我运行它时,我得到以下结果

    1 Scenarios (1 undefined)
    3 Steps (3 undefined)
    0m0.000s


    You can implement missing steps with the snippets below:

    Given("^I have this test\\.$", () -> {
        // Write code here that turns the phrase above into concrete actions
        throw new PendingException();
    });

    When("^I test This$", () -> {
        // Write code here that turns the phrase above into concrete actions
        throw new PendingException();
    });

    Then("^I get this$", () -> {
        // Write code here that turns the phrase above into concrete actions
        throw new PendingException();
    });

但我希望缺少的步骤在 java 中,如下所示:

    @Given("^I have this test\\.$")
    public void I_have_this_test() throws Throwable {
        // Write code here that turns the phrase above into concrete actions
        throw new PendingException();
    }

任何人都可以帮助我如何实现这一目标吗?

最佳答案

您正在获取 Java 8 的代码片段。请与我们分享您的依赖项。

我假设您有一个依赖项(使用 Maven 样式依赖项)

<dependency>
    <groupId>info.cukes</groupId>
    <artifactId>cucumber-java8</artifactId>
    <version>1.2.4</version>
</dependency>

相反,我认为您想依赖

<dependency>
    <groupId>info.cukes</groupId>
    <artifactId>cucumber-java</artifactId>
    <version>1.2.4</version>
</dependency>

使用构建工具中的依赖项更新您的问题,我们也许能够为您提供更多帮助。

关于java - Cucumber - 在 java 中实现缺失的步骤,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35300494/

相关文章:

cucumber - 在 SpecFlow 的示例表中包含表

java - 可以逃离 JUnit 测试用例吗?

java - 如何将多个对象写入可序列化文件并在程序再次使用时读取它们?

java - 正确使用带有自定义类的哈希表

java - Intellij idea中使用cucumber 4.6.0的步骤导航问题

ruby-on-rails - 如何在 Cucumber/Capybara 中设置浏览器语言?

java - 如何在 Selenium 的帮助下单击此下拉菜单?

java - 适用于 Mac OS X 的 Eclipse

ruby-on-rails - "eval"已弃用。请改用 "evaluate"

bdd - 漂亮的Gherkin功能文件输出