51Testing软件测试论坛

标题: Cucumber+Watir(BDD模式驱动) [打印本页]

作者: kokahkhk    时间: 2012-1-30 10:55
标题: Cucumber+Watir(BDD模式驱动)
本帖最后由 kokahkhk 于 2012-1-30 11:29 编辑

最近用Cucumber写了些case,发现这个框架模式不错,配合CI使用,可以进行关键字驱动并大批量运行并且生成report,不过维护起来比较麻烦点,不知道有没有人也在用着框架。下面是个Demo
附上生成的rpt

Feature: Baidu Search
  As a casual internet user
  I want to find some information about watir, and do a quick conversion
  So that I can be knowledgeable being

  Scenario Outline: Baidu Search
    Given that user goto baidu page
    When that user search for "<word>"
    Then that user see the watir result

    Examples:
      | word  |
      | watir |
      | test  |



require 'watir'
require 'rspec'


Given /^that user goto baidu page$/ do
  ie.goto "www.baidu.com"
end

When /^that user search for watir$/ do
  ie.text_field(:name,'wd').set 'Watir'
end

When /^that user search for "([^"]*)"$/ do |arg1|
  ie.text_field(:name,'wd').set (arg1)
end

Then /^that user see the watir$/ do
  ie.html.include?("watir").should == true

end

Then /^that user failed to see watir$/ do
  ie.html.include?("esdsds").should == false
end
作者: 奔雷    时间: 2012-5-21 15:58
我也在用 cucumber selenium-webdriver ruby jenkins,欢迎交流。@Given_When_Then 新浪微博
作者: dugang    时间: 2016-8-16 15:54
cucumber BDD采用自然语言描述自动化用例。
比较适合没有代码开发经验的测试人员使用。





欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2