Skip to content
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

Support for step parameters in Behave seems to be broken #230

Open
Cavaler opened this issue Sep 10, 2024 · 3 comments
Open

Support for step parameters in Behave seems to be broken #230

Cavaler opened this issue Sep 10, 2024 · 3 comments
Labels

Comments

@Cavaler
Copy link

Cavaler commented Sep 10, 2024

👓 What did you see?

The way the service parses Behave step definitions is in total disagreement with how Behave itself does.

In Behave tutorial, parameters in e.g. @then have the same name as the actual function parameter, and that is the way Behave later calls the step.

Example feature file:

Feature: Sending declarations

  Scenario: Declaration is sent at start
    Given Module "iot-modbus" is running
    Then Declaration for "iot-modbus" is present

and steps file:

from behave import given, then

@given('Module "{module}" is running')
def step_impl(context, module):
  pass

@then('Declaration for "{module}" is present')
def get_vmc_declaration(context, module):
  pass

Runs OK with Behave, but gives parsing errors in VS Code:

[Error - 2:10:20 PM] * Step Definition errors: Error: This Cucumber Expression has a problem at column 9:

Module "{module}" is running
        ^------^
Undefined parameter type 'module'.

✅ What did you expect to see?

Expected to properly parse the feature and steps files

📦 Which tool/library version are you using?

behave 1.2.6
VS Code 1.92.2
Cucumber extension 1.10

🔬 How could we reproduce it?

  1. Install VS Code
  2. Install Cucumber Extension
  3. Open folder containing the files from above

📚 Any additional context?

No response

@Cavaler
Copy link
Author

Cavaler commented Sep 10, 2024

Alternatively, when trying to generate steps from VS Code, this is what we get:

@then('Declaration for {string} contains {string}')
def step_then(context, string, string2):
  pass

And it is not recognized by Behave as a valid step because of parameter name mismatch. Declaration for {string} contains {string2} works in Behave, but not in VS Code.

@jenisys
Copy link

jenisys commented Sep 11, 2024

@Cavaler

  • Your initial description uses behave‘s parse expressions instead of cucumber-expressions
  • The cucumber language-service supports cucumber-expressions (and regexp for cucumber) only AFAIK
  • The latest behave version has support for cucumber-expressions build in: v1.2.7.dev5 (and v1.2.7.dev4). Otherwise, you need to use the cucumber-expressions package directly.

PROCEDURE:

  • Use behave HEAD from the Git repository of install behave via Git repo tag v1.2.7.dev5 (or newer)
  • But first verify that it works for you: Run your feature file with behave or use the feature-file for cucumber-expressions below
  • Then check that the VSCode cucumber language-server is working for you or not

SEE ALSO:

@Cavaler
Copy link
Author

Cavaler commented Sep 12, 2024

OK, this seems to be a duplicate for #205 then

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants