免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2165 | 回复: 0
打印 上一主题 下一主题

Watir自动测试应用(4):关于Ruby的自动测试框架 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-02-17 10:18 |只看该作者 |倒序浏览
转:whoami

Watir自动测试应用(4):关于Ruby的自动测试框架




对于TestCase的书写如下:
  1. require 'test/unit' #引用的自动测试类库

  2. #必须TestCase必须继承于Test::Unit::TestCase
  3. class TC_MyTest< Test::Unit::TestCase
  4.   def setup
  5.     #添加每个测试test预设环境参数
  6.     #注意这里指的是每个test不是TestCase
  7.   end

  8.   def teardown
  9.     #添加每个测试test清除环境参数
  10.   end

  11.   def test_case1
  12.     #判断失败
  13.     assert(false, 'Assertion was false.')
  14.   end

  15.   def test_case2
  16.     #判断成功
  17.     assert(true, 'Assertion was false.')
  18.   end
  19. end
复制代码
调用如下:

使用TestSuite
  1. require 'test/unit/testsuite'
  2. require 'tc_myfirsttests'

  3. class TS_MyTests
  4.    def self.suite
  5.      suite = Test::Unit::TestSuite.new
  6.      suite << TC_MyTest.suite
  7.      return suite
  8.    end
  9. end

  10. Test::Unit::UI::Console::TestRunner.run(TS_MyTests)
复制代码
如果也可以直接调用:
  1. require 'test/unit/ui/console/testrunner'
  2. Test::Unit::UI::Console::TestRunner.run(TC_MyTest)
复制代码
也可以使用命令行执行单一test:
  1. Ruby tc_myfirsttests.rb --name test_case1
复制代码
当然使用ecplise也是可以运行滴。。。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP