Cucumber lambdas for other languages

tacobot :

The classic way of step definition pre-Java 8 allows you to use the actual keywords of other languages for the annotations.

@前提("totally new stuff")
public void totallyNewStuff() {
    System.out.println("hello world")
}

What would be the equivalent of this as a Java 8 lambda?

I am assuming that the Cucumber test would work if I were to simply write the step definitions in English like so:

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

But that would defeat the purpose of localized Gherkin.

mpkorstanje :

For Japanese you implement the Ja interface instead of the En interface. But it's worth nothing that using 前提 or Given makes no functional difference. Steps are matched regardless of keyword.

import io.cucumber.java8.Ja;

public class RpnCalculatorSteps implements Ja {
    private RpnCalculator calc;

    public RpnCalculatorSteps() {

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

        });
    }
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=146670&siteId=1