阅读 test/unit 文档
1.需要 require 'test/unit'
2. 测试函数需要test开头
3. 可以加setup teardown
举个例子,
require 'test/unit'
class TC_MyTest < Test::Unit::TestCase
# def setup
# end
# def teardown
# end
def test_fail
assert(false, 'Assertion was false.')
end
end
可以用netbean 直接生成一个Ruby Unit Test 文件, 好像没有创建 setup和teardown函数
assert 表达式或者变量 ( 只有当表达式或者变量 true时候才通过测试)
assert_equal(表达式1, 表达式2)
小技巧
调试的时候, 几个测试用例放在一起, 当只想运行其中一个的时候, 只要把函数的test 头去掉,就不会自动运行了
1.需要 require 'test/unit'
2. 测试函数需要test开头
3. 可以加setup teardown
举个例子,
require 'test/unit'
class TC_MyTest < Test::Unit::TestCase
# def setup
# end
# def teardown
# end
def test_fail
assert(false, 'Assertion was false.')
end
end
可以用netbean 直接生成一个Ruby Unit Test 文件, 好像没有创建 setup和teardown函数
assert 表达式或者变量 ( 只有当表达式或者变量 true时候才通过测试)
assert_equal(表达式1, 表达式2)
小技巧
调试的时候, 几个测试用例放在一起, 当只想运行其中一个的时候, 只要把函数的test 头去掉,就不会自动运行了