简体   繁体   中英

How do I avoid ambiguous step definitions in Cucumber?

I'm running into ambiguous step definition errors. The following scenarios live in different feature files, and have one identical step: Then I should see my profile page . How do I avoid this from happening?

# authentication.feature
Scenario: Successful sign in
  Given I visit the sign in page
  When I submit valid sign in information
  Then I should see my profile page

# signing_up.feature
Scenario: Successful sign up
  Given I visit the sign up page
  When I submit valid information
  Then I should see my profile page

# authentication_steps.rb
...
Then /^I should see my profile page$/ do
  page.current_path.should == user_path(@user)
end

# signing_up.feature
...
Then /^I should see my profile page$/ do
  page.current_path.should == user_path(@user)
end

I'm running into this problem with error messages too:

Scenario: Unsuccessful sign up
  ...
  Then I should see an error message

Scenario: Unsuccessful login
  ...
  Then I should see an error message

Why not stay only with the one in authentication_steps.rb ? I think you can use all steps in any feature file

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM