RSPEC 能否处理 90% 通过的阈值测试?
我有一个分类函数,它确定一段文本是否属于一个类别(即返回真/假)。我有一系列现实世界的例子,我不希望它 100% 正确分类。
def meal?(text)
!text.match(/restaurant|meal|wine|.../i).nil?
end
RSPEC 能否指定一个测试,当我将这数百个示例提供给该函数时,只要正确识别 90%,就算通过?更好的是在报告中提供失败的 RSPEC 输出示例。如果可能的话如何编写这样的测试?
I have a classification function, which determines if a paragraph of text belongs to a category (i.e. it returns true/false). I have an array of real world examples, and I do not expect it classify correctly 100% of the time.
def meal?(text)
!text.match(/restaurant|meal|wine|.../i).nil?
end
Can RSPEC specify a test that, when I feed these hundreds of examples to that function, as long as 90% are identified correctly, then it counts as a pass? Even better would be to have RSPEC output examples that fails in the report. If it is possible how can one write such a test?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当然。
任何您可以比较或简化为布尔表达式的内容,RSpec 都可以处理……这几乎是软件中的所有内容。这只是弄清楚如何表达它的问题。
Sure.
Anything you can compare, or reduce to a boolean expression, RSpec can handle...which is pretty much everything in software. It's just a matter of figuring out how to express it.