ruby单元测试库
这几天在学ruby, 自己写了一个简单的单元测试库, 有点DSL的感觉。
似乎没有ruby的格式化, 用Lua凑合一下吧。
sample code:
require 'rUnit'
include RUnit

testSuite :SampleTestSuite do
setup do
end
tearDown do
end
testCase :TestEqualPass do
assertEqual 1.0, 4.0-3.0
end
testCase :TestEqualFail do
assertEqual 1, 2
end
testCase :TestFail do
assert 1>3
end
testCase :TestException do
raise 'Exception raised'
end
end
Output:
SampleTestSuite
Passed:TestEqualPass
Failed:TestEqualFail (Expected <1> but <2>.)
Failed:TestFail (Expected <true> but <false>)
Failed:TestException (Exception raised)
Lib Source:
rUnit
似乎没有ruby的格式化, 用Lua凑合一下吧。
sample code:
require 'rUnit'
include RUnit
testSuite :SampleTestSuite do
setup do
end
tearDown do
end
testCase :TestEqualPass do
assertEqual 1.0, 4.0-3.0
end
testCase :TestEqualFail do
assertEqual 1, 2
end
testCase :TestFail do
assert 1>3
end
testCase :TestException do
raise 'Exception raised'
end
end
Output:
SampleTestSuite
Passed:TestEqualPass
Failed:TestEqualFail (Expected <1> but <2>.)
Failed:TestFail (Expected <true> but <false>)
Failed:TestException (Exception raised)Lib Source:
浙公网安备 33010602011771号