使用VisualStudio2005TeamSystem進行單元測試[7] 軟件測試
Assert.IsTrue( (currentBalance + depositAmount) >
target.CurrentBalance,
"Deposit not applied correctly");
}
[TestMethod()]
public void MakePaymentTest() {
float currentBalance = 500;
BankAclearcase/" target="_blank" >ccount target = new BankAccount(currentBalance);
float paymentAmount = 250;
target.MakePayment(paymentAmount);
Assert.IsTrue(currentBalance - paymentAmount ==
target.CurrentBalance,
"Payment not applied correctly");
}
}
}
主單元測試概念 == 斷言
用于該形式單元測試的主要概念是,自動化單元測試是基于“斷言”的,即可定義為“事實或您相信為事實的內容”。從邏輯角度看,請考慮該語句“when I do {x}, I expect {y} as a result”。
原文轉自:http://www.anti-gravitydesign.com