cucumber / cucumber/language-service

Support for step parameters in Behave seems to be broken

Open
#230 8 comments 0 reactions 0 assignees View on GitHub
python
Dominant language
TypeScript
Stars
29
Forks
44
PR merge metrics
No merged PRs in 30d

Description

### 👓 What did you see?

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

In [Behave tutorial](https://behave.readthedocs.io/en/latest/tutorial/#step-parameters), 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:

```gherkin
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:

```py
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_

Contributor guide

Open the contributing guide

Research direction

Use the feature file and steps file examples in the report as the reproduction. Start at the language service's Behave step-definition parsing path and compare its parameter handling with Behave 1.2.6. Done means the example parses without an undefined-parameter-type error in VS Code.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, typescript, vscode
Domain
testing, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.