CustomAssert.Contains(expected, subscribers);
};
領域層
CustomerService類以真實web服務的名稱命名。在需求文檔、日常對話、架構圖以及代碼中,都用這個名稱來指代此web服務。 使用統一的名稱,能除去二義,提高溝通效率。
public class CustomerService
{
public Subscriber SearchWithTelephoneNumber(string telephoneNumber)
{
string url =
string.Format(
"{0}/subscribers?telephoneNumber={1}",
endpoint, telephoneNumber);
//Send http request to web service, parse the xml returned,
//populate the subscriber object and etc.
return GetResponse(url);
}
...
}
Subscriber類建模了用戶。比起用豎線分割的字符串,增加一層數據抽象,用對象表示返回的數據,能使 測試更容易理解(你應該不會偏好用pipedData[101]表示電話號碼吧?)。
public class Subscriber
{
文章來源于領測軟件測試網 http://www.kjueaiud.com/