Java 其他语言用黄瓜羔羊

Java 其他语言用黄瓜羔羊,java,java-8,cucumber,Java,Java 8,Cucumber,Java 8之前的经典步骤定义方法允许您使用其他语言的实际关键字进行注释 @前提("totally new stuff") public void totallyNewStuff() { System.out.println("hello world") } 作为Java8Lambda,它的等价物是什么 如果我简单地用英语写下步骤定义,我假设Cucumber测试会起作用,如下所示: Given("totally new stuff",() -> System.out.printl

Java 8之前的经典步骤定义方法允许您使用其他语言的实际关键字进行注释

@前提("totally new stuff")
public void totallyNewStuff() {
    System.out.println("hello world")
}
作为Java8Lambda,它的等价物是什么

如果我简单地用英语写下步骤定义,我假设Cucumber测试会起作用,如下所示:

Given("totally new stuff",() -> System.out.println("hello world"));

但这将破坏本地化小黄瓜的目的。

对于日本人,您实现的是
Ja
接口,而不是
En
接口。但是使用
前提
给定的
在功能上没有区别。不管关键字是什么,步骤都是匹配的

import io.cucumber.java8.Ja;

public class RpnCalculatorSteps implements Ja {
    private RpnCalculator calc;

    public RpnCalculatorSteps() {

        前提("totally new stuff", () -> {

        });
    }
}

请注意,包名实际上是
cucumber.api.java8.ja
io.cumber.java8
用于maven包(
io.cumber.cumber-java8
)。谢谢你!你可能想考虑升级你的黄瓜。我们快到v5了你什么意思?我只是在用maven的最新版本。老实说,cucumber有点陌生?你应该使用
io.cucumber
groupId中的依赖项。天哪,我刚刚意识到你是项目维护者!谢谢你回答我的问题。我使用的是v4.7.2,因为这是maven central上的最新版本,我的IDE自动完成将我指向
cucumber.api.java8.ja
。我假设
io.cucumber
在快照版本中生效?