Closed kbaum closed 15 years ago
Hi,
1) what is the reason of using "Given" after the "When" and "Then" Statement?
Normally: Given "Somthing" When you do "Something" Then there should be "Something" ... so given statements are always before when and then: e.g.: Given a And b When c Then d And e
2) in the english version ' is used for recognizing strings: "string" and 'string' , so you should use it only for strings and write something like I'll or I've as I will and I have and so on.
2) maybe I try to implement it, that it is possible to use ' in between of text like I'll and I've and so on ... should be not so hard ;)
Thanks for your response.
Regarding the extra given when and then statements, from an English perspective i think it makes sense:
Given I go to a page And I click on some button Then I should be on this page And I click on another button Then I should be on this other page
Most importantly, as a plugin, I think it makes sense to support whatever cucumber supports... nothing more and nothing less :-).
Thanks again!
-karl
you argumentation is not completely wrong, but your basic assumption (your scenario) is wrong, at least in my opinion. why? you are doing 2 things in one scenario, split it up into 2 would be better.
Scenario1: Action1 Given I am on a page When I click on some button Then I should be on this page And I've checked some properties
Scenario2: AfterAction1 Given I've done something before When I am on this page And I click on another button Then I should be on this other page
This would be a better way of coding it.
Even if cucumber supports its, my plugin tries to force you to write good scenarios ;)
cheers roland (QuBiT)
1) i've uploaded a new version 1.2.3 which allows you to write something like
And I've done ...
and so on. just uninstall the old one and reinstall the new downloaded one (as the version number has not changed.
I agree, it would be better in most cases to split up that scenario. But sometimes, it seems to me that even though a scenario is long, the steps just belong together. Take a registration/activation scenario:
Scenario: User registers
Given I am a user with email "barney.rubble@example.com"
When I go to the signup page
And I fill in "email" with "barney.rubble@example.com"
And I press "signup"
Then I should see "An activation email has been sent to your inbox."
And I should not be logged in
Then I should receive an email
When I open the email
Then I should see "Account Confirmation" in the subject
When I click the activation email link
Then I should be on the edit user page
And I fill in "Username" with "barney"
And I fill in "Password" with "secret"
And I fill in "Password Confirmation" with "secret"
And I press "save changes"
And I should see "Your profile has been updated."
When I follow "logout"
Then I should not be logged in
Then I should be able to login with username "barney" and password "secret"
Now I know that is long, but that scenario is valuable in a couple of ways.
1) It completely tests the flow from an end user perspective 2) It validates username/password were actually set without ever touching the database making it usable in a selenium environment.
Maybe the plugin should give a warning instead of an error and the warning should be configurable.
I'll give the new plugin a try. Thanks again for your help.
-karl
1st: i enabled this freedom in my module, so you can download version 1.2.4 which gives you that. Additionally I do not have tested cucumber with selenium yet, so this maybe one argument. (but I did it for you anyway ;) )
2nd: I have a different understanding of given/when/then which should describe what you have, what you do in 1 step and what you check after 1 step, resulting in more scenarios. Why don't make it more readable:
Scenario: User registers
Given I am a user with email "barney.rubble@example.com"
When I go to the signup page
And I fill in "email" with "barney.rubble@example.com"
And I press "signup"
Then I should see "An activation email has been sent to your inbox."
And I should not be logged in
And I should receive an email
Scenario: account confirmation
Given I received an registration confirmation email
When I open the email
Then I should see "Account Confirmation" in the subject
And I see the activation link
Scenario: activate account
Given I've opened the account confirmation email
When I click the activation email link
Then I should be on the edit user page
Scenario: Edit User Profile
Given I am on the edit user page
And I fill in "Username" with "barney"
And I fill in "Password" with "secret"
And I fill in "Password Confirmation" with "secret"
And I press "save changes"
And I should see "Your profile has been updated."
And I am logged in
Scenario: Logout
Given I am logged in
When I follow "logout"
Then I should not be logged in
and I should be able to login with username "barney" and password "secret"
Summary: Yes, now you can do this all in one scenario, which can be useful to run very long chains of commands, but you should additionally create small scenarios which test each element one bye one.
The plugin looks great but i noticed that in a couple of cases, it's indicating syntactical errors that do not exist.
1) When I continue with another "given" after a "then"
2) When I have a ' character in my feature file.
thx.