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

Glue code with escaped quotation marks is not recognized. #172

Closed
klauerm opened this issue Mar 27, 2023 · 4 comments
Closed

Glue code with escaped quotation marks is not recognized. #172

klauerm opened this issue Mar 27, 2023 · 4 comments
Labels
🐛 bug Defect / Bug java

Comments

@klauerm
Copy link

klauerm commented Mar 27, 2023

👓 What did you see?

I'm having the following step definition:

When I click on the icon for "Edit Expression"

The corresponding glue code search pattern is:

  @When("I click on the icon for \"Edit Expression\"")
  public void iClickOnTheIconEditExpression() { ... }

The cucumber extension does not recognize this glue code as step definition of the above step.

✅ What did you expect to see?

The corresponding IntelliJ plugin does recognize it.
When I execute my cucumber tests, they are working fine.
So I expect, that I can navigate from my feature file step to the glue code and the step isn't underlined as "Undefined Step"

📦 Which tool/library version are you using?

I'm using cucumber-java-4.3.1 with java version 11.

🔬 How could we reproduce it?

  • Define a feature file with a When-Step described above.
  • Generate a glue code (CTRL + .)
  • In the Annotation @When, replace the generated {string} with \"Edit Expression\"
@kieran-ryan
Copy link
Member

kieran-ryan commented Dec 30, 2023

Thanks for capturing @klauerm. This logic is defined in Cucumber Expressions; it advises the below output.

[Info  - 19:04:31] Scheduling reindexing in 3000 ms
[Info  - 19:04:32] Unable to generate step definition. Please create one first manually.
[Info  - 19:04:34] Reindexing file:///Users/<user>/repository
[Info  - 19:04:35] * Found 3 feature file(s) in ["src/test/**/*.feature","features/**/*.feature","tests/**/*.feature","*specs*/**/.feature"]
[Info  - 19:04:35] * Found 7 steps in those feature files
[Info  - 19:04:35] * Found 1 glue file(s) in ["features/**/*.java"]
[Info  - 19:04:35] * Found 0 parameter types in those glue files
[Info  - 19:04:35] * Found 0 step definitions in those glue files
[Error - 19:04:35] * Step Definition errors: Error: This Cucumber Expression has a problem at column 12:

I have an \"expression\"
           ^
Only the characters '{', '}', '(', ')', '\', '/' and whitespace can be escaped.
If you did mean to use an '\' you can use '\\' to escape it

Moving issue to Cucumber Expressions. Someone may be able to advise on most appropriate usage in this case, or whether any changes are required.

@kieran-ryan kieran-ryan transferred this issue from cucumber/vscode Jan 1, 2024
@mpkorstanje
Copy link
Contributor

mpkorstanje commented Jan 1, 2024

@klauerm you're using cucumber-java:4.3.1. This version of Cucumber uses an older version of Cucumbers expressions.

The grammar in that version is different than the one used by the vscode plugin. I don't think this this is what causes the mismatch but do consider upgrading to the latest version.

@kieran-ryan, it also looks like the vscode plugin doesn't handle escaped characters correctly. This step definition:

  @When("I click on the icon for \"Edit Expression\"")

Has, after handeling the Java escapes, the expression:

I click on the icon for "Edit Expression"

But it looks like the plugin takes the literal value from the annotation without handeling the escapes i.e:

I click on the icon for \"Edit Expression\"

This is probably a problem in the plugin.

@kieran-ryan kieran-ryan transferred this issue from cucumber/cucumber-expressions Jan 1, 2024
@kieran-ryan
Copy link
Member

Cheers @mpkorstanje! Transferred to Language Service where that logic is implemented, will plan to take a look into a fix

@kieran-ryan
Copy link
Member

Duplicates earlier #111

@kieran-ryan kieran-ryan closed this as not planned Won't fix, can't repro, duplicate, stale Apr 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Defect / Bug java
Projects
Status: Done
Development

No branches or pull requests

3 participants