[Ruby]???????
???????????? ???????[ 2013/8/14 15:05:06 ] ????????
????1. Test::Unit???
????Test::Unit???????????3????????????????????У?
????1) ????????????????????????
????2) ??????????????????????
????3) ?????????????????ò????
????Test::Unit?????ж?????????if???????????????????????????????????????????????????????????磺
require 'test/unit'
Class TestBug < Test::Unit::TestCase
def test_simple
assert_equal('ok'?? MyClass.new(1).to_s)
assert_equal('error'?? MyClass.new(2).to_s)
end
end
???????????????????????????磺
require 'test/unit'
Class TestBug < Test::Unit::TestCase
def test_raise
assert_raise(RuntimeError) {MyClass.new('null')}
assert_nothing_raised() {MyClass.new('normal')}
end
end
????2. ???????
??????????????????????????????????????????????????????????????????????????????????????????????????????????????в????
???????????????????Test::Unit::TestCase?????????ж???????????????test?????Test::Unit??÷?????????????е????????????test???????????????????
??????????????Щ?????????setup??teardown?????С??????TestCase???У????????setup????????????????????????У???????teardown???????????????????????????У????磺
require 'test/unit'
require 'dbi'
Class TestDB < Test::Unit::TestCase
def setup
@db = DBI.connetct('DBI:mysql:playlists')
end
def test_count
assert_equal('10'?? MyClass.new(1).get_count)
end
def teardown
@db.disconnect
end
end
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11