在使用任何语言进行测试时,每个人如何表达他们的断言消息?
我看到三种明显的方式:
# assume failure assert (4-2) == 2, "Subtracting 2 from 4 doesn't equal 2" # describe success assert (4-2) == 2, "Subtracting 2 from 4 should equal 2" # be vauge with failure assert (4-2) == 2, "Subtracting 2 from 4 is broken"
这显然是一个简单的例子,但你明白了.什么是标准做法?你是做什么?为什么?
我不知道标准做法是什么,但我将前两种方法与增加的实际结果相结合.
"Substracting 2 from 4 should equal 2, but equals " + value
这不容置疑,并且易于调试.