Ruby:我如何使用assert_nothing_raised?
发布时间:2020-12-17 03:10:05 所属栏目:百科 来源:网络整理
导读:assert_nothing_raised do @board.make_move(0,Board::HUMAN) end 并且文档说: Passes if block does not throw anything.Example: assert_nothing_thrown do [1,2].uniq end 我的make_move方法: def make_move(x,y,player) return false end 我收到错误:
assert_nothing_raised do @board.make_move(0,Board::HUMAN) end 并且文档说: Passes if block does not throw anything. Example: assert_nothing_thrown do [1,2].uniq end 我的make_move方法: def make_move(x,y,player) return false end 我收到错误: test_can_make_valid_move_in_the_first_row(BoardTest): ArgumentError: wrong number of arguments (1 for 2) 解决方法
以下代码适用于我.对你起作用吗?
require 'test/unit' require 'test/unit/ui/console/testrunner' class MyTestClass < Test::Unit::TestCase def test_something assert_nothing_raised do p 'hi' end end end Test::Unit::UI::Console::TestRunner.run(MyTestClass) 我认为你正在使用assert_nothing_raised.尝试更换 @board.make_move(0,Board::HUMAN) 用更简单的东西,比如 p 'hi' 并看看是否有效.还可以尝试在测试中注释掉所有其他代码. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |