matthewpietal / Eclipse-Plugin-for-Cucumber

Enables real-time validation and editing support for Cucumber feature files in Eclipse.
23 stars 10 forks source link

Step matching is dependent on which Given-When-Then-And you use #11

Closed rosswarren closed 8 years ago

rosswarren commented 11 years ago

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.

mrpotes commented 11 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 .

rosswarren commented 11 years ago

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!

mrpotes commented 11 years ago

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 .

CuriousAgilist commented 11 years ago

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".

rosswarren commented 8 years ago

closing 3 year old issue as never going to go anywhere 😄