cucumber / vscode

Official Visual Studio Code Extension for Cucumber
MIT License
65 stars 16 forks source link

Unable to go to step definition from feature file with Java serenity project #181

Closed srninni closed 5 months ago

srninni commented 11 months ago

👓 What did you see?

Not able to go to step definition from feature file. Getting a message, "Steps not found". Steps are there and even the tests are working, running successfully.

✅ What did you expect to see?

On right clicking on the gherkin statement and choode "Go to Step", i should land on the step

📦 Which tool/library version are you using?

serenity cucumber in Java

🔬 How could we reproduce it?

Steps to reproduce the behavior:

  1. Install '...' version '...'
  2. Create a file called '....'
  3. Run command '....'
  4. See error '....'

📚 Any additional context?


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

kieran-ryan commented 11 months ago

Hi @srninni, thanks for raising. Could you provide more information on the software versions used (serenity, VSCode, VSCode Cucumber extension) and the relative path to where your step definitions and feature files are stored?

srninni commented 11 months ago

Hi @kieran-ryan, thanks for the response, I tried both serenity version 2.0.39 and 4.0.0-beta-2 For VS Code Cucumber extension, I have v1.7.0 VS Code version 1.83.1

kieran-ryan commented 10 months ago

@srninni, can you provide:

A common pitfall is features or step definitions being stored in an unconventional directory. Can you advise whether your files are stored in locations matching the following glob paths?

kieran-ryan commented 6 months ago

@srninni, have experimented with Serenity and suspect the issue relates to the Cucumber Language Service not supporting the @Step and @But decorators. Otherwise, expression parsing errors can be observed in VSCode's Output window for the 'Cucumber Language Server'.

@mpkorstanje, for the Cucumber JVM, would you be able to advise are the supported decorators @Step, @And, @But, @Given, @When, @Then? And should we extend parsing support to all those decorators or keep to @Given, @When, and @Then? I will extend support if considered advisable.

mpkorstanje commented 6 months ago

Cucumber JVM generates the annotations from gherkin-languages.json with some small modifications to make it valid Java.

So not only is that Given, When, Then, and also And and But. But also every translation of those keywords.

For Serenity, from reading the docs, the @Step annotation is not for step definitions, but rather for logging.

https://serenity-bdd.info/docs/serenity/#first-steps

So to peel this onion, I think adding support for all the English keywords would be a good first step.

To add support for all the other translations, there are a few options I suppose you could investigate. If the language service supports meta annotations you could look for the presence of the @StepDefinitionAnnotation meta annotation. If not then it might be possible to generate all the keywords from the gherkin-languages.json. But that is decidedly more complicated so I can't really pass judgment on wether that is worth while doing or not.