Cucumberish
Cucumberish copied to clipboard
Why has "And" been deprecated
Thanks for a cool library. The MatchAll function doesn't recognize when you use an "And" in your feature file. I see that "And" has been deprecated too. This doesn't make sense to me, can you please explain what the thinking behind this is?
And
is now implicit. If you implement a match for Given
(or When
or Then
...) it will also work for And
. If you are finding that MatchAll
isn't matching for And
, that's a bug (cc: @TitouanVanBelle).
Can I fix the bug and send a pull request?
Can you provide more information about the scenario you're trying to run?
If you have an And after a Given, and you implement the And step with MatchAll it doesn't recognize that the step exists; for example:
Scenario: Delete an order of tickets
Given it is the tickets screen
And I confirm the "Delete" action
And you implement the step with MatchAll like this:
MatchAll("I confirm the \"(*.)\" action") {(args, userInfo) -> Void in
NSLog("Not implemented")
}
It doesn't recognise the step.
I see that the MatchAll function doesn't have Given:
void MatchAll(NSString * definitionString, CCIStepBody body)
{
When(definitionString, body);
Then(definitionString, body);
But(definitionString, body);
}
Yes, that's what I thought. Then feel free to create a PR adding the Given call in the MatchAll function. Unless there was a reason in the beginning for not adding it? @brentleyjones
It's just a bug. A PR would be wonderful, thanks.
In the documentation for Step Definitions:
Given is left out intentionally because it is very unlikely to have a case when a definition is suitable for Given and any other kind of steps.
This doesn't refer to a left out Given. It's about MatchAll not containing And.
@louismza, I'm referring to the comment above:
feel free to create a PR adding the Given call in the MatchAll function. Unless there was a reason in the beginning for not adding it
Oh yeah, but are we saying Given can’t have Ands?
I think the idea is that if And is used after When or Then, then it will be called by MatchAll. But MatchAll intentionally does not match Given, and as such, it won't match any Ands following Given.
That's my understanding of the way it works currently.
This is limiting because you can’t reuse a step defined With MatchAll in your Given clause. You can argue that the And step I am implementing here is supposed to be a When step. But I am not trying to implement invalid Cucumber. All steps defined in any way match all Givens, Whens, Thens and Ands in standard Cucumber. I.e. if you define a step with When() in standard Cucumber, you can match it with a Given without a problem.