White:一个新的Windows界面开发测试框架

发表于:2008-2-26 17:53

字体: | 上一篇 | 下一篇 | 我要投稿

 作者:未知    来源:网络转载

        一种新的界面测试框架发布了,名为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 Image

        第一个按钮只有一个非常简单的动作,即当你点击它时,它的名称会改为“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 access.
#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技术,这意味着你不用担心用什么来写你的界面测试,也不用考虑你的界面是否使用了不同的技术

《2023软件测试行业现状调查报告》独家发布~

精彩评论

  • nic162534
    2009-3-03 16:10:59

    我在试用了。确实不错。以前一直用Watin,现在有了White也可以测试C/S结构的程序了。

关注51Testing

联系我们

快捷面板 站点地图 联系我们 广告服务 关于我们 站长统计 发展历程

法律顾问:上海兰迪律师事务所 项棋律师
版权所有 上海博为峰软件技术股份有限公司 Copyright©51testing.com 2003-2024
投诉及意见反馈:webmaster@51testing.com; 业务联系:service@51testing.com 021-64471599-8017

沪ICP备05003035号

沪公网安备 31010102002173号