Skip to content

Defining several steps for the same function #895

@javierseixas

Description

@javierseixas

Is there any way to have more than one step definition (of the same type) for the same function? Something like:

@Then("^it's do something$")
@Then("^it's do another thing$")
public void this_is_my_function() throws Throwable {
    // Do something
}

I now that in Behat (PHP) and Specflow (C#) it is possible.

I'm getting the following error:

Error:(86, 5) java: cucumber.api.java.en.Then is not a repeatable annotation type

I found a post talking about a workaround for Java 7, and a solution for Java 8 using @Repeatable.

I tried the Java 7 approach but it doesn't work either:

@Thens({
    @Then("^it's do something$")
    @Then("^it's do another thing$")
})

I guess I should define @Thens as a new annotation type, but I would like to depend only in what the library has.

Is it possible to include the `@Repetable' annotation in the code?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions