Cucumber 将 TypeRegistryConfiguration 转换为 ParameterType 注释 JAVA

Cucumber converting TypeRegistryConfiguration to ParameterType annotation JAVA

由于 TypeRegistry io.cucumber.core.api.TypeRegistry@Deprecated 我在声明参数注释时遇到了麻烦,我现在知道如何将它们转换为 @ParameterType

我试过了

@ParameterType(value = ".*", name = "foo")
public String foo(String foo) {
    return "foobar";
}

@ParameterType("foo")
@When("I type {foo}")
public void iType(String string) {
    System.out.println(string);
}

该步骤识别此参数并进行编译,但出现以下错误:

io.cucumber.java.InvalidMethodSignatureException: A @ParameterType annotated method must have one of these signatures:
 * public Author parameterName(String all)
 * public Author parameterName(String captureGroup1, String captureGroup2, ...ect )
 * public Author parameterName(String... captureGroups)
at com.dsm.steps.RequestAccessSteps.withTheInformationIconContaining(java.lang.String)
Note: Author is an example of the class you want to convert captureGroups to

但老实说我不明白他们想说什么

错误是我将 @Parametertype("foo") 放在步骤上方,但那不是必需的,因此引发了错误。否则它工作得很好。

所以这有效:

public String foo(String foo) {
    return "foobar";
}

@When("I type {foo}")
public void iType(String string) {
    System.out.println(string);
}