使用VisualStudio2005TeamSystem进行单元测试[7]

发表于:2010-05-13来源:作者:点击数: 标签:单元
使用VisualStudio2005TeamSystem进行单元测试[7] 软件测试 Assert.IsTrue( (currentBalance + depositAmount) target.CurrentBalance, "Deposit not applied correctly"); } [TestMethod()] public void MakePaymentTest() { float currentBalance = 500; Ba

  使用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.ltesting.net