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

Cucumber-在java中实现缺少的步骤,java,cucumber,gherkin,Java,Cucumber,Gherkin,我有下面的Cumber特性,没有任何相应的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 st

我有下面的Cumber特性,没有任何相应的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风格的依赖)


信息杯
黄瓜-java8
1.2.4
相反,我认为你应该依靠

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

信息杯
黄瓜爪哇
1.2.4

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

您能否提供一些详细信息,说明您发布的最后一个代码段不起作用的原因?这只是一个例子:Cucumber建议您使用lambda表达式(Java8中引入的一个新特性),但您希望使用传统的Java方法,这也很好。您使用的是什么命令?好像红宝石黄瓜在跑。谢谢。我将“cumber-java8”改为“cumber-java”,效果很好。
<dependency>
    <groupId>info.cukes</groupId>
    <artifactId>cucumber-java</artifactId>
    <version>1.2.4</version>
</dependency>