White:一個新的Windows界面開發測試框架 軟件測試
一種新的界面測試框架發布了,名為White。White與WatiN類似,它封裝了微軟的UIAutomation庫和Window消息,可以用于測試包括Win32,WinForm,WPF和SWT(Java)在內的軟件。ThoughtWorks的Vivek Singh是該項目的Leader,他已將White放在了CodePlex上。White具有面向對象的API,很容易來控制一個應用,它也可以與xUnit.Net,MbUnit,NUnit,MSTest這樣的測試框架結合使用,甚至Fit.Net也可以。
Ben Hall就如何使用White寫了一篇非常好的教程,該教程以示例清晰地說明White與WatiN和Selenium何其相似。
第一個按鈕只有一個非常簡單的動作,即當你點擊它時,它的名稱會改為“Hello World!!”。其測試代碼如下:
[Test]
public void ButtonClickable_btnClick1_ChangesText()
{
Application application = Application.Launch(path);
Window window = application.GetWindow("White Hello World", InitializeOption.NoCache);
Button button = window.Get("btnClick1"); #1
//Moves the mouse to click the button
button.Click(); #2
Assert.AreEqual("Hello World!!", button.Name); #3
}
#1 Using the Get method, we can give it the type and name of the control we want to aclearcase/" target="_blank" >ccess.
#2 We can then call the Click method which will move the mouse cursor over to the button and click it.
#3 We can then verify that the action was correctly performed, in this case the Name has changed.
Ben還展示它的其它方面,例如根據可見文字搜索控件,未處理的異常,消息框,以及測試的可讀性和非常有用的輔助工具UISpy。該教程還對White給予了較高評價。
這個框架給我留下非常深刻的印象。盡管還缺少一些很好的特性(譯者注:比如無法優雅地測試Outlook中的Toolbar),但希望它們會不斷被追加進來。事實上,這個框架使用了多種不同的UI技術,這意味著你不用擔心用什么來寫你的界面測試,也不用考慮你的界面是否使用了不同的技術。
原文轉自:http://www.anti-gravitydesign.com