Closed rosswarren closed 8 years ago
I've noticed this behaviour too, but I'd regard it as a bug in cucumber, not the plugin - why have 5 different annotations if you aren't going to treat them differently?
On 27 February 2013 14:27, Ross Warren notifications@github.com wrote:
Cucumber does not distinguish between Given, When, Then, And. So if you write a step definition for "Then I do something" you can use the step as "And I do something" and it will still work. However, the plugin only matches steps if they use the same word.
— Reply to this email directly or view it on GitHubhttps://github.com/matthewpietal/Eclipse-Plugin-for-Cucumber/issues/11 .
This is intended functionality in cucumber.
For example if you have two "Thens" Then I should see a Then I should see b
In your Cucumber feature you would write these as the following Then I should see a And I should see b
But, in another feature if you only wanted to see b you would write it as the following Then I should see b
But it is the same step definition!
Yeah, if it were me, I'd have three (english) annotations, Given, When, Then, that indicate the stage of the scenario they could be used in. So And/But are just connectives to the level that the step is resolved from.
So, for an example like yours
@Given("I could see (.+)") @When("I see (.+)") @Then("I should see (.+)") public void doISee(String it) {...}
Obviously you're right that the plugin doesn't allow as much as cucumber does (my plugin makes the same restriction, as it happens), but I think that leads to more readable code as a result.
On 27 February 2013 15:38, Ross Warren notifications@github.com wrote:
This is intended functionality in cucumber.
For example if you have two "Thens" Then I should see a Then I should see b
In your Cucumber feature you would write these as the following Then I should see a And I should see b
But, in another feature if you only wanted to see b you would write it as the following Then I should see b
But it is the same step definition!
— Reply to this email directly or view it on GitHubhttps://github.com/matthewpietal/Eclipse-Plugin-for-Cucumber/issues/11#issuecomment-14180116 .
matthew: "regard it as a bug in cucumber, not the plugin". Really?
You might want consider that the JVM platform (and hence this Eclipse plugin) are only one of many language platforms that use the Cucumber framework. Suggesting that Cucumber should work differently because a tool you've written to support it's usage doesn't, seems a bit ...how should I say this... naive. I use this plugin daily and appreciate what it does well. But that's not to say it cannot be improved by better supporting the framework it's designed to support the use of.
mrpotes: How would you propose to limit what a Given vs. a When vs. a Then method can do, i.e. define distinct "stages"? I'm having trouble figuring out how less flexibility will result in "more readable code".
closing 3 year old issue as never going to go anywhere 😄
Cucumber does not distinguish between Given, When, Then, And. So if you write a step definition for "Then I do something" you can use the step as "And I do something" and it will still work. However, the plugin only matches steps if they use the same word.