Search code examples
cucumberoptional-parameterscucumber-java

Cucumber converting TypeRegistryConfiguration to ParameterType annotation JAVA


Since TypeRegistry io.cucumber.core.api.TypeRegistry is @Deprecated I have troubles declaring my parameter annotations, I have now idea how to transform them to the @ParameterType

I tried this

@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);
}

the step recognises this parameter and it compiles but I get following error:

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

but honestly I dont understand what they are trying to say


Solution

  • The fault is I put the @Parametertype("foo") above the step but thats not necessary and thus throwing the error. It works perfectly fine otherwise.

    So this works:

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