編譯并運行-黃色的狀態條。點擊“Tests Not Run”,在列表里你會看到e bank.AccountTest.TransferWithInsufficientFundsAtomicity() ,而且帶有測試忽略的原因:
看一下我們的測試代碼,我們會發現某些重構是有順序的。所有測試方法都共享一組通用的測試對象。我們將這個初始化代碼提取到一個setup方法里,并在所有測試中重用它。我們測試類的重構版本如下:
namespace bank
{
using System;
using NUnit.Framework;
[TestFixture]
public class AccountTest
{
Account source;
Account destination;
[SetUp]
public void Init()
{
source = new Account();
source.Deposit(200.00F);
destination = new Account();
destination.Deposit(150.00F);
}
[Test]
文章來源于領測軟件測試網 http://www.kjueaiud.com/