Visual Studio 2008单元测试实践[2]

发表于:2010-04-26来源:作者:点击数: 标签:实践单元StudioVisualvisual
Visual Studio 2008 单元测试 实践[2] 软件测试 public float CurrentBalance { get { return _currentBalance; } set { _currentBalance = value; } } public BankAccount(float initialBalance) { this._currentBalance = initialBalance; } public void d

       Visual Studio 2008单元测试实践[2]   软件测试

  public float CurrentBalance

  {

  get { return _currentBalance; }

  set { _currentBalance = value; }

  }

  public BankAclearcase/" target="_blank" >ccount(float initialBalance)

  {

  this._currentBalance = initialBalance;

  }

  public void depositMoney(float depositAmount)

  {

  this._currentBalance += depositAmount;

  }

  public void makePayment(float paymentAmount)

  {

  this._currentBalance -= paymentAmount;

  }

  }

  }

  要对BankAccount类进行单元测试,只需要在BankAccount的定义处鼠标右键,在菜单中选择“Create Unit Tests”即可进入测试项目的创建工作。如下图所示:

  在弹出的创建单元测试的对话框中,对需要创建测试的方法和属性进行选择,然后点击“OK”按钮,如图所示:

原文转自:http://www.ltesting.net