1
在我的測試中NodeUnit,我有這樣一段代碼:doesNotThrow在Node.js的返回undefined
exports['aTest'] = function(test){
...
var functionResult = test.doesNotThrow(aFunction(aParam));
...
}
但爲什麼test.doesNotThrow functionResult被調用後未定義,doesNotThrow(...) ()不返回函數調用的結果? 這將是相當優雅。
返回未定義嚴格地不如返回調用didNotThrow(...)所做的結果。 – lOlive
這是因爲這是單元測試,您正在測試函數不會拋出,在另一個測試中,您將測試結果並查看它是否符合您的期望。 –
我想知道爲什麼鏈接斷言被認爲是不好的做法。參考這篇文章http://stackoverflow.com/questions/2430429/are-multiple-asserts-bad-in-a-unit-test-even-if-chaining – lOlive