Add step override #2310
champagnearden
started this conversation in
Ideas
Replies: 1 comment
|
Cucumber Ruby did something where it tried to give preference to the longest expression. But while that could overlap with a more specific step definition when very simple expressions are used, it isn't always the case. It is also quite opaque to users so I don't think this would be the right approach. Adding a priority to step definitions seems feasible though. You might want to create a feature request with the Cucumber implementation you are using. That said. It seems there is a distinction between regular and stateful buttons, wouldn't writing |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
In a E2E project you may test to check buttons are visible so you have a step like
And I see the {string} buttonthat auto-detect the button based on its text value.Therefore sometimes you need a specific action when a specific button is clicked (state depends on a variable), so you would need to override that step like
And I see the 'Hello World' buttonIf you try and do that you will have the
Multiple matching step definitionserrorThis is where steps override comes in action !
Instead of writing a switch-case or if-else (or even use a regex) cucumber would detect the second one is narrower than the generic one (less generic operator
{string}) or even have a decorator like@Priority(X)to place before step definition, or input it as an optional parameter with default priority set to 0.So in an extreme case like
And I see the {string} element is {string} with value {string}you could narrow it down while keeping the fallback case (pls don't useThen("{string}", () => {})...)Wyt ?
All reactions