maximehamm / tzatziki

Cucumber y Tzatziki
26 stars 7 forks source link

Support for custom parameter matching #28

Closed zdbrandt closed 2 years ago

zdbrandt commented 2 years ago

Hello!

I am not sure if this request belongs in Cucumber+ or the IntelliJ board. Please let me know if I should move it.

My company uses a package called pickled-cucumber which extends some of the functionality of Cucumber. One of the features it provides is some out-of-the-box parameter matching. For example, the {variable} parameter in a step definition maps to the regex value (\w+).

This enables the team to write a step definition such as Then("the error message contains the username {variable}", (username) => { /* logic here */ })

which could then be used in a feature file by Then the error message contains the username testUser

Currently in Webstorm v2021.3.1 and Cucumber+ v11.1.3 (though this also happened on previous versions), when I try to use these step definitions, I get the warning Undefined step reference even though the tests run properly. I also cannot use code completion or go-to-definition.

Is this something that you'd be able to help with with Cucumber+?

Edit: I forgot to mention, this is supported in VS Code by adding parameter/value objects to cucumberautocomplete.customParameters in settings.json such as

{
   "parameter": "{variable}",
   "value": "(\\w+)"
}
maximehamm commented 2 years ago

Hello Zach The reference between gherkin steps and code is not managed by Cucumber+ but by other plugins dedicated to each supported language : cucumber for Java, cucumber for Scala, cucumber.js, etc... As I understand, you're using Javascript ? then you should install cucumber.js... is it done ? If this will not solve your problem, I think you should share with pickled-cucumber about this. Happy new year Zach !

zdbrandt commented 2 years ago

Happy New Year!

Yes, I'm using JavaScript. The cucumber.js plugin is installed. I will reach out to the creators of the cucumber.js plugin to see if they can support custom parameters. Thanks for the help.