佳丽

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
在用ruby做测试时,很多时候需要一些数据初始化以及事后的数据恢复还原之类的操作,下面整理了这些方法。
require "test/unit"


class TestAnion <Test::Unit::TestCase
#用例执行前只执行一遍初始化数据
def self.startup
anion='startup'
puts anion
end
#用例执行后只执行一遍初始化数据
def self.shutdown
puts "shutdown"
end
#每一执行一个用例之前执行
def setup
puts "setup"
end
#每执行一个用例之后执行
def teardown
puts "teardown"
end
#case
def test_01_fir
puts "first"
end
def test_02_sec
puts "second"
end
end

 

 
posted on 2016-07-21 17:52  佳丽  阅读(240)  评论(0编辑  收藏  举报