MILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">总结:微软将单元测试功能从Visual Studio 2005 Team System开始集成到开发环境中,是经过了微软公司多年的实践经验证明的。如今,开发环境从以前的单一开发功能,将关注点分散到软件的整个生命周期过程中来,已经成为一个ALM平台。软件开发人员不仅需要做开发工作,而且需要对自己开发的代码进行单元测试,不能将所有的问题全部抛给测试人员。测试人员可以将更多的精力放在系统一级的测试工作上面。
using BankAccountDemo.Business;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace BankAccountDemo.Business.Tests
...{
[TestClass()]
public class BankAccountTest
...{
private TestContext testContextInstance;
public TestContext TestContext
...{
get
...{
return testContextInstance;
}
set
...{
testContextInstance = value;
}
}
Additional test attributes#region Additional test attributes
#endregion
[TestMethod()]
public void CurrentBalanceTest()
...{
float initialBalance = 0F; // TODO: Initialize to an appropriate value
BankAccount target = new BankAccount(initialBalance); // TODO: Initialize to an appropriate value
float expected = 0F; // TODO: Initialize to an appropriate value
float actual;
target.CurrentBalance = expected;
actual = target.CurrentBalance;
Assert.AreEqual(expected, actual);
Assert.Inconclusive("Verify the correctness of this test method.");
}
[TestMethod()]
public void makePaymentTest()
...{
float initialBalance = 0F; // TODO: Initialize to an appropriate value
BankAccount target = new BankAccount(initialBalance); // TODO: Initialize to an appropriate value
float paymentAmount = 0F; // TODO: Initialize to an appropriate value
target.makePayment(paymentAmount);
Assert.Inconclusive("A method that does not return a value cannot be verified.");
}
[TestMethod()]
public void depositMoneyTest()
...{
float initialBalance = 0F; // TODO: Initialize to an appropriate value
BankAccount target = new BankAccount(initialBalance); // TODO: Initialize to an appropriate value
float depositAmount = 0F; // TODO: Initialize to an appropriate value
target.depositMoney(depositAmount);
Assert.Inconclusive("A method that does not return a value cannot be verified.");
}
[TestMethod()]
public void BankAccountConstructorTest()
...{
float initialBalance = 0F; // TODO: Initialize to an appropriate value
BankAccount target = new BankAccount(initialBalance);
Assert.Inconclusive("TODO: Implement code to verify target");
}
}
}
文章来源于领测软件测试网 https://www.ltesting.net/