You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I believe, according to the behavior I am seeing in some of my tests, and in the source code, that step definitions are implemented in a way that is different than the Gherkin definition.
According to the definition the key word (Given, When, or Then) should not be taken into account when initially loading a step definition. However, you should not be allowed to use Given and Then on the same step definition within the same scenario.
I have the case where I've defined a When step definition using the When Attribute, but I am invoking that step definition underneath a Give (using And however). When running with Xunit, I am told that I am missing a step definition.
My setup looks something like the following, for clarity:
Step definition
let [<When>] ``I have defined a step definition`` () = ()
Feature: Test Feature
Scenario: All initial keywords are fair game
Given I am writing a test
And I have defined a step definition
When I call it with a different keyword initially
Then the step definition should succeed
Please let me know if this is not intended functionality, or if it is functioning as intended. This was just unexpected behavior compared to my previous BDD experience.
The text was updated successfully, but these errors were encountered:
TickSpec isn't the only BDD framework which differentiates the step types, e.g. I think SpecFlow does the same. However, SpecFlow has both [<When>], [<Then>], [<Given>] attributes and it also has [<StepDefinition>] attribute which would be closer to what Cucumber does but I didn't see that used much.
We could potentially have such attribute but you can do the same today by writing:
let [<Given; When; Then>]``I have defined a step definition`` ()=()
Semantically the And and But keywords can be seen just as a replacement for one of Given, When, and Then keywords based on context.
Ah, I did not realize I could add Given, When, and Then to the same step definition. That allows me to accomplish what I'm looking for I believe. I've always treated all the keywords as the exact same thing in my mind. Thank you for the help :)
I believe, according to the behavior I am seeing in some of my tests, and in the source code, that step definitions are implemented in a way that is different than the Gherkin definition.
https://docs.cucumber.io/gherkin/reference/#steps
According to the definition the key word (
Given
,When
, orThen
) should not be taken into account when initially loading a step definition. However, you should not be allowed to useGiven
andThen
on the same step definition within the same scenario.I have the case where I've defined a
When
step definition using theWhen
Attribute, but I am invoking that step definition underneath aGive
(usingAnd
however). When running with Xunit, I am told that I am missing a step definition.My setup looks something like the following, for clarity:
Step definition
Please let me know if this is not intended functionality, or if it is functioning as intended. This was just unexpected behavior compared to my previous BDD experience.
The text was updated successfully, but these errors were encountered: