cucumber test  小心得 二


Scenario: Signing up
Given I am on the homepage
When I follow "Sign up"
And I fill in "Email" with "user@ticketee.com"
And I fill in "Password" with "password"
And I fill in "Password confirmation" with "password"
And I press "Sign up"
Then show me the page
Then I should see "You have signed up successfully."
Failed assertion, no message given. (MiniTest::Assertion)
/Users/ryanbigg/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/minitest/unit.rb:85:in `assert'
/Users/ryanbigg/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/test/unit/assertions.rb:19:in `assert'
./features/step_definitions/web_steps.rb:105:in `block (2 levels) in <top (required)>'
./features/step_definitions/web_steps.rb:13:in `with_scope'
./features/step_definitions/web_steps.rb:101:in `/^(?:|I )should see "([^\"]*)"(?: within "([^\"]*)")?$/'
features/signing_up.feature:14:in `Then I should see "You have signed up successfully."'

Failing Scenarios:
cucumber features/signing_up.feature:6 # Scenario: Signing up


是你的web_steps.rb写的不好

 #写step 定义的时候,加上提示信息就会好了
Then /^(?:|I )should see "([^"]*)"$/ do |text|
if page.respond_to? :should
page.should have_content(text)
else
assert page.has_content?(text), "no text has been found"
end
end


验证排序

Then /I should see "(.*)" before "(.*)"/ do |e1, e2|
# ensure that that e1 occurs before e2.
# page.content is the entire content of the page as a string.
movies_list = page.all("table#movies>tbody>tr>td").map(&:text)
assert movies_list.index(e1) < movies_list.index(e2), "#{e1} is not before #{e2}"
#assert false, "Unimplmemented"
end



Capybara.default_selector = :css
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值