Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby 如何使用测试/单元检查运行时错误_Ruby_Unit Testing_Testing - Fatal编程技术网

Ruby 如何使用测试/单元检查运行时错误

Ruby 如何使用测试/单元检查运行时错误,ruby,unit-testing,testing,Ruby,Unit Testing,Testing,在我的程序中,我使用raise“text”来防止在参数错误时创建对象 如何在测试/单元中检查此项 assert_ ? (MyObject.new(wrong,parameter)) 如何检查我的对象是否未创建 def test_illegal assert_raise( RuntimeError ) { MyObject.new('a') } end

在我的程序中,我使用raise“text”来防止在参数错误时创建对象

如何在测试/单元中检查此项

assert_ ? (MyObject.new(wrong,parameter))
如何检查我的对象是否未创建

def test_illegal
  assert_raise( RuntimeError ) { MyObject.new('a') }
end