作者热门文章
- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
assert_nothing_raised do
@board.make_move(0,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,0,Board::HUMAN)
用更简单的东西,比如
p 'hi'
看看是否可行。还可以尝试注释掉测试中的所有其他代码。
关于Ruby:如何使用 assert_nothing_raised?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4843858/
assert_nothing_raised do @board.make_move(0,0,Board::HUMAN) end 文档说: Passes if block does not th
从 Rails 6.0.3 升级到 6.1 时,我遇到了这个错误: NoMethodError: undefined method `assert_nothing_raised' for
我是一名优秀的程序员,十分优秀!