Chr*_*s C 2 nunit unit-testing ruby-on-rails
我想知道是否有一种方法可以将参数传递给与 NUnit 的TestCase Attribute类似或想法相似的 rails 中的单个测试。谢谢
在 Ruby(和 Python)中进行参数化测试的方式是动态创建测试方法:
[[12, 3, 4], [12, 2, 6], [12, 4, 3]].each do |n, d, q|
test "#{q} is the quotient of #{n} and #{d}" do
assert_equal q, n/d
end
end
Run Code Online (Sandbox Code Playgroud)
确保测试名称包含数据。