Unable to go to step definition from feature file with Java serenity project
srninni opened this issue ยท 5 comments
๐ 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:
- Install '...' version '...'
- Create a file called '....'
- Run command '....'
- See error '....'
๐ Any additional context?
This text was originally generated from a template, then edited by hand. You can modify the template here.
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?
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
@srninni, can you provide:
- an example feature file - and its relative path to the root of your workspace
- an example step definition - and its relative path to the root of your workspace
- any configured extension settings - suggest to double-check that the paths to your glue and feature files match the default glob paths
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?
-
feature files
{ "cucumber.features": [ "src/test/**/*.feature", "features/**/*.feature", "tests/**/*.feature", "*specs*/**/*.feature" ] }
-
glue files
{ "cucumber.glue": [ "src/test/**/*.java", "features/**/*.js", "features/**/*.jsx", "features/**/*.ts", "features/**/*.tsx", "features/**/*.php", "features/**/*.py", "tests/**/*.py", "tests/**/*.rs", "features/**/*.rs", "features/**/*.rb", "*specs*/**/*.cs" ] }
@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.
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.