-
-
Notifications
You must be signed in to change notification settings - Fork 696
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
Optional text not working as expected #767
Comments
Just for benefit (Although you have half done it), you "could" reproduce the failing code. As you could create a feature that just printed I'll try reproduce this issue, but as I'm a rubyist, this may be a java-centric problem. I don't know without a full repro scenario. The best type of reproduction scenario is a failing test against our CI. See if you can do that, using our code. It could be your environment is causing some issue. There are lots of factors here. |
@luke-hill if this really is a bug, it's likely present in all implementations (including Ruby). The easiest way to reproduce it is to write a failing test in |
Hey not sure if this is what you meant but I added a couple tests in how we are trying to use it? |
That's exactly the kind of thing that's brilliant thanks. Although obviously those use cases don't cover the full extent of ones you mentioned. If you could add the ones you are physically using so we have a close repro scenario and then make it as a PR, it'll run through our CI and it'll automatically flag whether they fail or not. Giving us a much easier time to triage. Thanks for your swift response. |
@spatel1009 considering this: assertEquals(emptyList(), match("three (brown )mice/rat/easter", "three brown mice")); I think the cucumber expression parser gets confused here. Is Another way to approach this is to write a slightly lower level test in CucumberExpressionPatternTest and assert what regexp you expect this to be translated into. |
Add a few of our expected stepdefs to the CucumberExpressionTest or create a separate repo with a drawn out stepdef/feature file flow? |
I have added a test to this with the expected regex. |
There seems to be quite some ambiguity we'd have to resolve first I think. What is the meaning of
If the latter we'd have to make the rewrite rules include optionals when rewriting alternatives. If the former we we'd have to stop matching alternatives at whitespace, |
Sure so we don't have many cases of this but the way the regexTest I wrote may explain better but the regex version allows for brown mice, brown rat, mice, rat. Basically all 4 variations and we we attempting to do that with cucumber expressions. |
Cucumber expressions are intended to be a simpler alternative to regular expressions. So if you are trying to do all that with cucumber expressions you may want to consider defining multiple step definitions or sticking with regular expressions. Still there is a bug here. |
Yes we are definitely leaning towards breaking them out since we want to move away from regex completely and utilize cucumber expressions solely. |
Some more interesting cases:
|
Splits the cucumber expression into text, optional, alternative and parameter tokens. This ensures that rewriting optionals does not interfere with rewriting alternatives. Currently processing and splitting is interleaved because the processing step may transform a token back into a text token again after handling its escapes. Fixes: #767 Closes: #770
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in a week if no further activity occurs. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in a week if no further activity occurs. |
This issue has been automatically closed because of inactivity. You can support the Cucumber core team on opencollective. |
Splits the cucumber expression into text, optional, alternative and parameter tokens. This ensures that rewriting optionals does not interfere with rewriting alternatives. Currently processing and splitting is interleaved because the processing step may transform a token back into a text token again after handling its escapes. Fixes: #767 Closes: #770
Splits the cucumber expression into text, optional, alternative and parameter tokens. This ensures that rewriting optionals does not interfere with rewriting alternatives. Currently processing and splitting is interleaved because the processing step may transform a token back into a text token again after handling its escapes. Fixes: #767 Closes: #770
Summary
When using optional text in the stepdef, it is not being read by the Gherkin as expected
Expected Behavior
Would like to use optional word where it is applicable to all alternative words following and not just the first one listed. Currently the third option below is what we are using since in that scenario only call needs the word test in front of it, but for future use may be instances were multiple alternative text have that optional word in front and would like to have possibility of being interchangeable.
Current Behavior
the( test) chat/email/call interaction is not visible
only reads: "And the test chat/email/call interaction is not visible"
Will not read: "And the chat interaction is not visible"
Nor singular: "And the test chat interaction is not visible"
Summary: Will only read where "test" is used and not optional with all 3 alternative words also included in the Gherkin
the (test) chat/email/call interaction is not visible
Will read "And the test call interaction is not visible"
But not "And the call interaction is not visible".
Summary: Will read only when test is put in front of the 3 options, not without. Basically renders "test" not optional
"the (test )call/email/chat interaction is not visible"
Will read "And the test call interaction is not visible"
And also:
"And the chat interaction is not visible"
But not
"And the test chat interaction is not visible"
Summary: Will read the use of test when in front of call only, not for email or chat.
Steps to Reproduce (for bugs)
Unable to provide company code, however, creating a stepdef that needs optional words in front of 2 out of 3 alternative text directly following it will help recreate issue.
Context & Motivation
This issue is for non-capture groups so this allows for more clear readable gherkin linking to same test for multiple portions of app.
Your Environment
Java
The text was updated successfully, but these errors were encountered: