Reputation: 2381
I am using cucumber with protractor. Is is possible in Cucumber to have for the same method more than one annotation??
For example something like this:
this.Given(/^I log in as user '([^']*)' with password '([^']*)'$/
this.When(/^I log in as user '([^']*)' with password '([^']*)'$/, function(username, password)
{
}
Upvotes: 1
Views: 1635
Reputation: 4343
From Cucumbers perspective, there is no difference betwen Given
and Then
. The different keywords are there just to enhance the readbility of the .feature
file. When you implement the steps, you can choose to use any of them.
Personally, I would never consider two different annotations for the same method. One is sufficient. The place where it matters is in the scenario and there I would use whatever I need.
At the same time, I am a but interested in why you describe you system using one Given
and one Then
step that actually are the same thing. The Given
is where you prepare the system under test, the Then
is where you assert that the expected outcome has occured. It feels surprising to me that they are actually the same execution in your case. Maybe there is a reason, but it seems strange to me at the moment.
Upvotes: 2