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

Highlight undefined steps in Scenario Outlines #90

Closed
kiran-epic opened this issue Aug 4, 2022 · 10 comments · Fixed by cucumber/language-service#210
Closed

Highlight undefined steps in Scenario Outlines #90

kiran-epic opened this issue Aug 4, 2022 · 10 comments · Fixed by cucumber/language-service#210
Labels
⚡ enhancement Request for new functionality

Comments

@kiran-epic
Copy link

kiran-epic commented Aug 4, 2022

When using scenario outline for data-driving with the help of examples, The following issues occur :

  • Only the parameters which are present in the Examples table are highlighted. For example in the below image, the "EducatorLogin" & "Dashboard" parameters are not highlighted as it's mentioned directly in the step as they don't change so no need to put it in the Examples table
    image

  • The missing step highlighter/generator doesn't run if there is an example table in the scenario. For example in the below image, the step Given QWERTY is invalid, but it's not highlighted & pressing Cmd+. doesn't give to generate a step definition for it.
    image

But if the example table is removed, it starts highlighting the step & also suggests action to generate step definition
image
image

@aslakhellesoy
Copy link
Contributor

This is actually by design.

Highlighting of parameters is done by matching steps against step definitions. For steps in regular scenarios we can do this. For steps in scenario outlines it is tricky to do, because each outline step becomes multiple steps after the <> is substituted.

Consider this example:

Scenario Outline:
  Given I have <count> cukes in my <container>
  
  Examples:
    | count | container |
    |     4 | basket    |
    |     7 | bag       |

This becomes two scenarios, each with the following step:

  • Given I have 4 cukes in my basket
  • Given I have 7 cukes in my bag

Now, imagine we have two step definitions with the following expressions:

  • I have 4 cukes in my {word}
  • I have {int} cukes in my bag

The first step would match the first expression, and the second step would match the second expression. Each match has only a single parameter.

How should we highlight in this case?

I suppose a compromise could be to highlight using matches if there are no <> placeholders, and highlight the <> placeholders otherwise.

@aslakhellesoy
Copy link
Contributor

@kiran-epic any feedback on my proposal?

@kiran-epic
Copy link
Author

@aslakhellesoy That sounds good to me!

@kiran-epic
Copy link
Author

@aslakhellesoy Would you also fix the bug where the autocomplete & missing step highlighter stops working when using Examples ?

@aslakhellesoy
Copy link
Contributor

I haven’t offered to fix anything, just discussing a potential solution.

This project relies on contributions from our community.

@cgarzon11
Copy link

cgarzon11 commented Apr 13, 2023

Hi! I have the same problems as @kiran-epic working with scenario outlines, can somebody suggest a temporal solution until this bug will be fixed? Mainly for the most important problem the missing step highlighter/generator doesn't run working with scenarios outlines

Thank you!

@kieran-ryan
Copy link
Sponsor Member

kieran-ryan commented Sep 25, 2023

Captured a feature request for this support in the Cucumber Language Service - where the changes would be required - with some possible considerations and options (cucumber/language-service#149). If you have any feedback, that would be great - to help define the necessary changes to see this implemented.

@Alphapage
Copy link

Same problem for me, but even with Scenario : not only Scenario Outline.
A workaround is to comment the Examples table, but latest version 1.8.0 removes the comments on save !!!
It would be great to generate at least the first Step definition to remove the highlighting when Outline.
Examples seems to be the problem to me and must be ignored by the extension for syntax highlighting...
The emergency problem is to be able to keep comments on save.

@kieran-ryan
Copy link
Sponsor Member

@Alphapage, deletion of trailing comments is resolved by cucumber/gherkin-utils#38 and will be available following a gherkin-utils release of merged changes and thereafter of a Visual Studio Code extension release.

@Alphapage
Copy link

Sorry, I read it was fixed in v.1.8.0 somewhere or I misunderstood something...
Thank you anyway for the clarification and I hope the extension will be updated soon +1

@kieran-ryan kieran-ryan added the ⚡ enhancement Request for new functionality label Dec 3, 2023
@kieran-ryan kieran-ryan changed the title Unexpected behavior when using Examples for Scenario Outline Highlight undefined steps in Scenario Outlines Jan 2, 2024
@kieran-ryan kieran-ryan pinned this issue Jan 6, 2024
@kieran-ryan kieran-ryan unpinned this issue May 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⚡ enhancement Request for new functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants