`

watir testUnit单元测试

    博客分类:
  • ruby
阅读更多

watir testUnit单元测试

 

简单示例:

require 'test/unit'
require 'watir'

class GoogleHomePage < Test::Unit::TestCase
  def test_Google
    browser = Watir::IE.start "http://www.google.com"
    assert(browser.text.include?("google.com.hk"))
  end

 

   def test_Baidu

    browser = Watir::IE.start "http://www.baidu.com"
    assert(browser.text.include?("百度"))
  end
end

注:

1.require 'test/unit'

2.定义类class,继承Test::Unit::TestCase

3.定义方法名def ,方法名以test开头

4.多个测试方法执行顺序:按字母顺序执行,比如上面的会先执行百度,再执行google测试。

5.方法里要有assert语句

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics