-
-
Notifications
You must be signed in to change notification settings - Fork 18
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
vscode cucumber-language-server: Quoted parameters in steps cause undefined-step in editor #110
Comments
Hey @c92s, thanks for your interest in the project 👋 There are some nuances to be aware of when using the extension with Behave; which I will describe below; and will hopefully get you up and running with the extension.
Beyond detecting step definitions, the extension will detect steps in your feature files and provided completions for them when writing other specifications; which should work without issue. The output window can provide greater insight into what the extension is doing and what matches it detected: Mentioning your original issue in case others encounter so they can reference this answer: behave/behave#1173. |
Thanks for your answer. I did the following according to your guidance.
However, I am still wondering, on which side (behave or cucumber) the error resides, when using Feature: Some new feature
Scenario: Some Scenario
Given user "foo" # implementation gets recognized
Given pass "bar" # underlined with "undefined step"
Given item baz # implementation gets recognized from behave import step
# {string} contains the quotation marks, this messes with the python
# implementation. However, the cucumber language server recognizes this
# function.
@step("user {string}")
def step_impl(context, string):
assert string == "foo", f"user <{string}> is not <foo>"
# This python implemenation works, however the cucumber language server does
# not recognize this function
@step('pass "{string}"')
def step_impl(context, string):
assert string == "bar", f"pass <{string}> is not <bar>"
# This works -->
@step('item {}')
def step_given(context, string):
assert string == "baz", f"item <{string}> is not <baz>" The language server output contains the following
In here, the lang-server identified the 3 step definitions.... |
The extension evaluates Matching with
|
Hi @kieran-ryan thanks for the information. I guess I will stick to the |
👓 What did you see?
When using the official Cucumber VSCode extension with the Python behave package, some steps with string variables are underlined and marked as "Undefined step".
✅ What did you expect to see?
A (string) parameter in Gherkin is passed in quotation marks as such:
Given pass "foobar"
. The respectivebehave
implementation is done as such:The problem is, that the Cucumber extension cannot find the implementation, as the quotation marks "{string}" are interpreted as part of the keyword. When removing them in the decorator, the quotation marks from the Gherkin keyword are not escaped and passed as part of the string. Therefor, the following implementation leads to an error:
📦 Which tool/library version are you using?
VSCode: 1.88.0
Cucumber Extension: v1.10.0
🔬 How could we reproduce it?
Create a gherkin
features/test_step.feature
file:Create the python step definition
features/steps/steps.py
:Lastly, run it with
$ behave features/
📚 Any additional context?
I see two possibilities on how to solve this:
@step('pass "{string}"'
)behave
is able to strip quotation marks in the passed parameter, so decorators like this are possible@step("user {string}")
I am not sure, however, which may be the ideal solution. Maybe you can give me some feedback. I already posted the issue in the official
behave
repository, but was forwarded to the cucumber language-server repo.The text was updated successfully, but these errors were encountered: