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

In Python, all steps in Scenarios show as undefined, even for plain text matchers #226

Closed
The-BDD-Coach opened this issue Apr 22, 2024 · 8 comments
Labels
🙅 wontfix This will not be worked on

Comments

@The-BDD-Coach
Copy link

👓 What did you see?

Using either Behave or Pytest-BDD-NG, most (probably all) steps are underlined, indicating that there are no matching step definitions. Right-clicking on a step and selecting 'Go to definition' says 'No definition for (the word the cursor is on)'. All of these step definitions worked in last year, but I don't know when they became broken.

✅ What did you expect to see?

All of these steps should NOT be underlined, and selecting 'Go to definition' should go to the step definition.

📦 Which tool/library version are you using?

Version: 1.88.1
Commit: e170252f762678dec6ca2cc69aba1570769a5d39
Date: 2024-04-10T17:43:08.196Z
Electron: 28.2.8
ElectronBuildId: 27744544
Chromium: 120.0.6099.291
Node.js: 18.18.2
V8: 12.0.267.19-electron.0
OS: Darwin arm64 23.4.0

Cucumber for VSCode v1.10.0

🔬 How could we reproduce it?

A minimal example is here: https://github.com/The-BDD-Coach/Step-Definition-Bug/tree/main

📚 Any additional context?

[Info - 10:19:21 AM] Initializing connection from Visual Studio Code 1.88.1
[Info - 10:19:21 AM] Root uri : file:///Users/leslie/Development/SBE_Class_Materials/temp/Python
[Info - 10:19:21 AM] Current dir : /
[Info - 10:19:21 AM] Registering request handler for workspace/didChangeConfiguration failed.
[Info - 10:19:21 AM] Client does not support client/registerCapability. This is OK.
[Info - 10:19:21 AM] Cucumber Language Server 1.6.0 initialized
[Info - 10:19:21 AM] Scheduling reindexing in 3000 ms
[Info - 10:19:21 AM] Scheduling reindexing in 3000 ms
[Info - 10:19:21 AM] Reindexing file:///Users/leslie/Development/SBE_Class_Materials/temp/Python
[Info - 10:19:21 AM] * Found 0 feature file(s) in ["src/test//*.feature","features//.feature","tests/**/.feature","specs//*.feature"]
[Info - 10:19:21 AM] * Found 0 steps in those feature files
[Info - 10:19:21 AM] * Found 0 glue file(s) in ["specs/
/.cs","features/**/.js","features//*.jsx","features//.php","features/**/.py","features//*.rs","features//.rb","features/**/.ts","features//*.tsx","features//_test.go","src/test/**/.java","tests//*.py","tests//*.rs"]
[Info - 10:19:21 AM] * Found 0 parameter types in those glue files
[Info - 10:19:21 AM] * Found 0 step definitions in those glue files
[Info - 10:19:21 AM] * Built 0 suggestions for auto complete
[Info - 10:19:21 AM] Unable to generate step definition. Please create one first manually.

@The-BDD-Coach The-BDD-Coach changed the title In Python, most (I think All) steps in Scenarios show as undefined, even for plain text matchers In Python, all steps in Scenarios show as undefined, even for plain text matchers Apr 22, 2024
@kieran-ryan
Copy link
Member

kieran-ryan commented Apr 22, 2024

Cheers @The-BDD-Coach - this is most helpful.

You will observe from the logs that the extension Found 0 feature file(s) and Found 0 glue file(s). This occurs as the extension's default paths (visible in the logs), expect them to be relative to the workspace that is open within VSCode.

However, based on the Root uri, VSCode is open in a Python parent directory of Step-Definition-Bug. Thus, when it searches for "features/**/*.py", it searches for step definitions within Python/features/**/*.py rather than Python/Step-Definition-Bug/features/**/*.py. Suggest to either configure the extension for multi-root or nested workspaces or open Step-Definition-Bug with VSCode directly. Let me know if any help required with either 👍

Due to the differences between regular expressions in Python and JavaScript, it fails to match your step definition that uses a regular expression - specifically on the 'search_term' portion. We can repurpose this report to examine reconciling that issue and move it to the Language Service repository.

Screenshot 2024-04-22 at 17 12 48

@neskk
Copy link

neskk commented Apr 22, 2024

Hello guys,
I'm having a similar issue using pytest-bdd, but I don't want to hijack the thread.

I'm having an issue where even adding the right glue configuration I get this:

[Info  - 1:41:17 PM] * Found 13 feature file(s) in ["src/test/**/*.feature","features/**/*.feature","tests/**/*.feature","*specs*/**/*.feature","**/tests/**/*.feature"]
[Info  - 1:41:17 PM] * Found 172 steps in those feature files
[Info  - 1:41:17 PM] * Found 36 glue file(s) in ["src/test/**/*.java","features/**/*.js","features/**/*.jsx","features/**/*.ts","features/**/*.tsx","features/**/*.php","features/**/*.py","tests/**/*.py","tests/**/*.rs","features/**/*.rs","features/**/*.rb","*specs*/**/*.cs","**/step_defs/**/*.py"]
[Error - 1:41:17 PM] Failed to reindex: Cannot read properties of null (reading 'type')

How can I see more information on the error "Failed to reindex"? What failed?

Thank you

@kieran-ryan
Copy link
Member

kieran-ryan commented Apr 22, 2024

Hey @neskk 👋 Looks like cucumber/language-service#181; are you using the latest version of the extension (v1.10.0), or otherwise if you can configure the extension to point to specific glue files to localise the issue and then share the file causing the issue, I’d be happy to investigate 👍

@neskk
Copy link

neskk commented Apr 22, 2024

I was using v.1.09 in WSL and had v.1.10 on host machine.
Reloading and updating to v1.10 solved the reindex error indeed, thank you!

Now I'm getting this (similar repo):

[Info  - 7:25:56 PM] * Found 13 feature file(s) in ["src/test/**/*.feature","features/**/*.feature","tests/**/*.feature","*specs*/**/*.feature","**/tests/**/*.feature"]
[Info  - 7:25:56 PM] * Found 172 steps in those feature files
[Info  - 7:25:56 PM] * Found 36 glue file(s) in ["src/test/**/*.java","features/**/*.js","features/**/*.jsx","features/**/*.ts","features/**/*.tsx","features/**/*.php","features/**/*.py","tests/**/*.py","tests/**/*.rs","features/**/*.rs","features/**/*.rb","*specs*/**/*.cs","**/step_defs/**/*.py"]
[Info  - 7:25:56 PM] * Found 0 parameter types in those glue files
[Info  - 7:25:56 PM] * Found 0 step definitions in those glue files
[Info  - 7:25:56 PM] * Built 22 suggestions for auto complete

I'll look into this, maybe parameter types are not defined.

@kieran-ryan
Copy link
Member

I was using v.1.09 in WSL and had v.1.10 on host machine. Reloading and updating to v1.10 solved the reindex error indeed, thank you!

Awesome - delighted our latest release resolved the issue!

I'll look into this, maybe parameter types are not defined.

This refers to Cucumber Expressions parameter types which are natively unsupported in pytest-bdd at present, so would be expecting 0 parameter types in your case. However I see 0 step definitions detected which may be a result of us not fully supporting all matcher variants of pytest-bdd at present though can also occur if the path configuration for glue files is pointed to a different location than our step definitions - though assuming is not the case here.

Feel free to open an issue on the Language Service; if you can also create a minimum reproducible example of definitions that are not getting detected; and link it, that can be really helpful. PRs are also welcome of course.

@The-BDD-Coach
Copy link
Author

@kieran-ryan Good catch on the directories; thank you!

Pytest-BDD-NG does support Cucumber Expressions, but the VSCode plugin doesn't know how to parse the matcher syntax. I wrote cucumber/language-service#204

It also doesn't handle Pytest-BDD-NG Regular Expressions; I wrote cucumber/language-service#203

@kieran-ryan
Copy link
Member

kieran-ryan commented Apr 22, 2024

@kieran-ryan Good catch on the directories; thank you!

Great! Ok to close this issue in that case with the new opened issues @The-BDD-Coach?

@The-BDD-Coach
Copy link
Author

I think that is the right thing to do.

@kieran-ryan kieran-ryan closed this as not planned Won't fix, can't repro, duplicate, stale Apr 22, 2024
@kieran-ryan kieran-ryan added the 🙅 wontfix This will not be worked on label Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🙅 wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

3 participants