您的位置:首页 > 移动开发

开源测试框架White

2009-11-11 10:21 274 查看
 
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何其相似。
 
 
主页:
http://white.codeplex.com/wikipage
 
GetStarted指南:
http://white.codeplex.com/wikipage?title=Get%20Started&referringTitle=Home
 
 
简单使用:
1、下载解压White_Bin_0.18.zip
 
2、导入相关dll
 
3、编写测试代码:
 
using System;
using System.Collections.Generic;
using System.Text;
using Core.UIItems.WindowItems;
using Core.UIItems;
using Core;
using NUnit.Framework;
using Core.Factory;
 
namespace WhiteTest1
{
    [TestFixture]
    public class Class1
    {
        private string path = @"E:/tmp/AutoBuild/Latest/MyProject/MyProject/bin/Debug/MyProject.exe";
 
        [Test]
        public void ButtonClickable_btnClick1_ChangesText()
        {
            Application application = Application.Launch(path);
            Window window = application.GetWindow("Form1", InitializeOption.NoCache);
            Button button = window.Get<Button>("button1");
            button.Click();
            Label label = window.Get<Label>("label1");
            Assert.AreEqual("OK!", label.Text);
        }
    }
}
 
4、像运行Nunit测试一样运行White测试
 
 
 
相关资源:
http://www.infoq.com/cn/news/2008/02/White-project
http://blog.benhall.me.uk/2008/02/project-white-automated-ui-testing.html
 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息