Ruby 对于testunit或其他nunit风格的框架来说,什么是好的失败消息?
在Ruby的test/unit和其他类似nunit风格的框架中,什么是好的失败消息 故障消息是否应仅描述预期值与预期值不匹配的原因Ruby 对于testunit或其他nunit风格的框架来说,什么是好的失败消息?,ruby,unit-testing,nunit,testunit,Ruby,Unit Testing,Nunit,Testunit,在Ruby的test/unit和其他类似nunit风格的框架中,什么是好的失败消息 故障消息是否应仅描述预期值与预期值不匹配的原因 assert_match("hey", "hey this is a test", "The word does not exist in the string") 它是否应该描述你期望发生的事情 assert_match("hey", "hey this is a test", "I expected hey to be in the string") ass
assert_match("hey", "hey this is a test", "The word does not exist in the string")
它是否应该描述你期望发生的事情
assert_match("hey", "hey this is a test", "I expected hey to be in the string")
assert_match("hey", "hey this is a test", "Program should provide a greeting")
它是否应该描述您希望这种行为发生的原因
assert_match("hey", "hey this is a test", "I expected hey to be in the string")
assert_match("hey", "hey this is a test", "Program should provide a greeting")
它是否应该描述您认为考试可能失败的原因
assert_match("konnichiwa", "konnichiwa this is a test",
"Program failed to use supplied i18n configuration")
关于测试的信息是否也应该存在于测试方法的名称和测试用例的名称中
这是基于故障消息应该为故障消息添加上下文。因此,任何节省您必须深入测试代码以了解失败的内容的方法 因此,如果[method name,expected,actual]集合足以满足上述目的,则可以跳过失败消息。如果需要更多信息,请添加可选的失败消息 e、 g。
预期为真,但为假
,没有告诉我任何事情
您可以使用失败消息,以便
返回值应仅包含10的倍数。预期为真,但为假
您可以首先尝试使用更具描述性的匹配器。
因此,读取的失败预期所有项都可以被10整除,但[10,20,35,40]
确实如此
就我个人而言,我更喜欢媒人。。。使用失败消息作为最后手段。(因为与注释一样,它会衰减。如果更改检查,您需要遵守规则以确保故障消息得到更新。)就我个人而言,我不在乎,我很高兴没有消息,通常我需要知道的是两个字符串不匹配这是我喜欢rspec的原因之一:)