我对我的问题感到有点难过.我使用的是ruby 1.8.7,rails 2.3.2.我正在尝试使用测试单元2.3.0中的"省略"功能.这是我的测试:
def test_create_reward_program
omit("Pending")
reward_program = RewardProgram.find_by_program_name("test_foo")
assert_equal "test_foo", reward_program.program_name
end
Run Code Online (Sandbox Code Playgroud)
当我运行'rake test'时,我得到以下内容:
1) Error:
test_create_reward_program(AwardControllerTest):
Test::Unit::OmittedError: Pending
/test/functional/award_controller_test.rb:43:in `test_create_reward_program'
148 tests, 261 assertions, 0 failures, 1 errors, 0 pendings, 0 omissions, 0 notifications
Run Code Online (Sandbox Code Playgroud)
0%通过
我不知道为什么它将它标记为"错误"时应将其标记为"遗漏".谁知道?
我也注意到这确实有效:
def test_create_reward_program
omit "Pending" do
reward_program = RewardProgram.find_by_program_name("test_foo")
assert_equal "test_foo", reward_program.program_name
end
end
Run Code Online (Sandbox Code Playgroud)
我找到的所有教程和示例都表明我的第一个例子应该可行.