使用VisualStudio2005TeamSystem进行单元测试[7] 软件测试
Assert.IsTrue( (currentBalance + depositAmount) >
target.CurrentBalance,
"Deposit not applied correctly");
}
[TestMethod()]
public void MakePaymentTest() {
float currentBalance = 500;
BankAccount 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”。
文章来源于领测软件测试网 https://www.ltesting.net/