jlagerweij / cucumber-kotlin

Jetbrains plugin for Cucumber step definitions written in Kotlin
https://plugins.jetbrains.com/plugin/10527-cucumber-for-kotlin
Other
20 stars 16 forks source link

Highlighter/navigator doesn't understand optional text in Gherkin expressions #33

Open jlous opened 3 years ago

jlous commented 3 years ago

My step uses gherkin expression syntax, and contains optional text marked accordingly with parentheses: Given("power is (already )on") {...} (see https://cucumber.io/docs/cucumber/cucumber-expressions/#optional-text)

The scenario using it runs perfectly, but the editor gets it wrong: If I include the optional text (power is already on), the editor highlights "already" as if it was a parameter. If I omit the optional text (power is on), the editor marks the whole clause as "undefined step reference"

It looks like the matcher always treats parentheses as parameters like in regex syntax, even though the step actually uses gherkin syntax. Other parts of gherkin syntax work fine, for instance {string} params

jlagerweij commented 3 years ago

As it turns out, the fix is not that difficult. I have created 2021.1.1 release, this should be available via the plugins download of JetBrains as soon as they review it.

jlous commented 3 years ago

Thanks, it works, but unfortunately there is an important regression:

It seems that regex-syntax is not recognised any more. It was before, and it works fine with cucumber. Regex is still very useful when you want more complex or fine-grained matching than cucumber syntax affords, like params within optional clauses.

Should I post this as separate issue?

jlagerweij commented 3 years ago

Can you give an example of what is not recognised? And("^the product id is (\\d+)$") The above does work for navigation.

Maniulo commented 3 years ago

Something like this is not working for me on 2021.1.1 and works fine on 2021.1.0: And("^Product (?: with id (\\d+))? is valid")

jlagerweij commented 3 years ago

Ah, I now see the problem and have submitted 2021.1.2 for review to Jetbrains