Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide multiple annotations support for Cucumber-JVM #1341

Closed
priyasetty opened this issue Apr 6, 2018 · 9 comments
Closed

Provide multiple annotations support for Cucumber-JVM #1341

priyasetty opened this issue Apr 6, 2018 · 9 comments
Labels
⌛ stale Will soon be closed by stalebot unless there is activity
Milestone

Comments

@priyasetty
Copy link

Summary

Provide multiple annotations support for Cucumber-JVM

Expected Behavior

@and("^the response body tag "(.)" contains the following values:$")
@then("^the response body attribute "(.
)" contains the following values:$")
@then("^the response body XPath"(.*)" contains the following values:$")

Current Behavior

we get below error if we use same annotation and if we change the annotation and use the step then we get undefined step.
java: cucumber.api.java.en.Then is not a repeatable annotation type

Possible Solution

we need these multiple annotations with same code logic as while reading the gherkin it makes more sense for PO's and other stake holders.

Note : Specflow supports multiple annotations

Your Environment

below is the cucumber version that i'm using in my project.

    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-core</artifactId>
        <version>2.4.0</version>
    </dependency>
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-java</artifactId>
        <version>2.4.0</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-junit</artifactId>
        <version>2.4.0</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-picocontainer</artifactId>
        <version>2.4.0</version>
        <scope>test</scope>
    </dependency>
@mlvandijk
Copy link
Member

mlvandijk commented Apr 7, 2018

Hi @priyasetty,
I was able to use all three steps provided without error. Have a look at my project.
Note that I'm using (.*) in my step definitions to capture Strings, instead of your "(.)" and "(.*)". Could you give this a try?
Also note that your provided example is missing a space between XPath and "(.*)".

Cucumber does not distinguish between the keyword used (Given, When, Then) when matching a step. You should be able to use the same step and stepdef with different keywords in your scenarios.

Perhaps I'm not understanding your question correctly; in which case, could you please provide some more information? (for instance your feature file?)
You can also contact us on on Slack to discuss. (Register for an account here if you don't already have one.)

@mlvandijk
Copy link
Member

@mpkorstanje pointed out I had misunderstood your question. You mean you want to use multiple annotations on one step definition, i.e. to have multiple regex match to that step def.
I've updated my project to illustrate; although using different keywords to prevent error.

Using repeating annotations is a Java 8 feature, while afaik Cucumber-jvm is still on Java 7.

This feature would need Java 1.8; the main hurdle there is we don't know how well Android supports it and we currently have nobody that knows Android.

In the mean time, as a workaround you could try using your annotations with different keywords (Given, When, Then, And, But); the keywords are not matched as part of the step definitions so you could annotate with different keywords than you are using in your feature file. This would give you the option to use at least 5 different matches per step definition.

@brasmusson
Copy link
Contributor

This looks like a duplicate of #957.

@priyasetty
Copy link
Author

priyasetty commented Apr 11, 2018

Yup @mlvandijk , currently I can use max of 5 different matches per step def and unfortunately the step file looks awkward, so fixing this shall help us

if I put Then keyword or any same keyword multiple times for different matches
it throws below error

Duplicate annotation. The declaration of 'cucumber.api.java.en.Then' does not have a valid java.lang.annotation.Repeatable annotation.

@priyasetty
Copy link
Author

any ETA to fix this?

@mpkorstanje
Copy link
Contributor

How soon will my ticket be fixed?

The best way to have a bug fixed or feature request implemented is to fork the cucumber-jvm repo and send a pull request. If the pull request has good tests and follows the coding conventions (see below) it has a good chance of making it into the next release.

You're welcome to help out. I reckon the best place to start would be:

This feature would need Java 1.8; the main hurdle there is we don't know how well Android supports it and we currently have nobody that knows Android.

@stale
Copy link

stale bot commented Jul 13, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in a week if no further activity occurs.

@stale stale bot added the ⌛ stale Will soon be closed by stalebot unless there is activity label Jul 13, 2018
@stale
Copy link

stale bot commented Jul 20, 2018

This issue has been automatically closed because of inactivity. You can support the Cucumber core team on opencollective.

@lock
Copy link

lock bot commented Jul 20, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jul 20, 2019
@mpkorstanje mpkorstanje added this to the 5.0.0 milestone Jul 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
⌛ stale Will soon be closed by stalebot unless there is activity
Projects
None yet
Development

No branches or pull requests

4 participants