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

Generic annotation for @Given @When @Then @And #2705

Open
ntthaibk opened this issue Mar 16, 2023 · 5 comments
Open

Generic annotation for @Given @When @Then @And #2705

ntthaibk opened this issue Mar 16, 2023 · 5 comments
Assignees
Labels
⚡ enhancement Request for new functionality

Comments

@ntthaibk
Copy link
Contributor

ntthaibk commented Mar 16, 2023

🤔 What's the problem you're trying to solve?

When I create the journey scenario. I use the * syntax in .feature file instead of normal Given When Then And. But then in those step's step definition, the @given or @when @then @and annotation is not able to differentiate the Journey step and normal integration test steps.

✨ What's your proposed solution?

I think another alias annotation for @StepDefinitionAnnotation is gonna be a good solution, it could be named either @Steps or @Journey

⛏ Have you considered any alternatives or workarounds?

For now I use @and as annotation for journey step

📚 Any additional context?

I don't know if we need to take into consideration for other framework that build on top of cucumber, because when I'm using Serenity, I think they already use @step for another purpose


This text was originally generated from a template, then edited by hand. You can modify the template here.

@ntthaibk ntthaibk added the ⚡ enhancement Request for new functionality label Mar 16, 2023
@mpkorstanje
Copy link
Contributor

I'd be happy to take a pull request that adds this.

To do this it would probably be best to change the GenerateI18n.java so that in addition to generating a localized annotation for every io.cucumber.java.<lang> it also generates a @Step annotation in the io.cucumber.java package.

@ntthaibk
Copy link
Contributor Author

ntthaibk commented Mar 20, 2023

hi @mpkorstanje, so I checked the Generatel18n.java today, and found out that actually I need to modify the Gherkin Dialect in order to add the @Step for auto generation and I saw the repo already archived, can I send the MR for the archived repo there, thanks

@ntthaibk ntthaibk self-assigned this Mar 20, 2023
@mpkorstanje
Copy link
Contributor

You can find the code for Gherkin in cucumber/gherkin. What made you believe it was cucumber/gherkin-java?

@ntthaibk
Copy link
Contributor Author

ahh I see, I thought it was gherkin-java after a google search with the keyword GherkinDialect.java

@mpkorstanje
Copy link
Contributor

Btw, updating languages.json is not the right way to go. It will also make Step a valid keyword to use in Gherkin.

I don't think you'd have to change languages.json anyway . There already is the * keyword. However isn't rendered as an annotation because it is an invalid class name and filtered out. You could replace it with something that is valid.

private void writeKeyWordAnnotations(GherkinDialect dialect) {
dialect.getStepKeywords().stream()
.filter(it -> !it.contains(String.valueOf('*')))
.filter(it -> !it.matches("^\\d.*"))
.distinct()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⚡ enhancement Request for new functionality
Projects
None yet
Development

No branches or pull requests

2 participants