在OpenExpressApp - 使用VS2010的CodedUI来做自己的自动化测试框架中介绍了我将使用IronRuby进行测试框架的编写。虽然Ruby已经非常的流行,我所在公司有的项目也深入的应用过,但它对于我来说还是非常新的,对它的认识也就是快速的看过基本书籍,并未实际使用过,而IronRuby又是在Ruby在.Net中的实现,我就更不了解了,所以现在只能边学边写边想了。
编写rb脚本文件
通过几篇文章的学习,写了一个简单的测试脚本,如下TestApplication.rb:
#require 'D:\GZJ\OpenExpressApp\Tool\UITest\Ruby\TestApplication.rb'
$LOAD_PATH << 'D:/GZJ/OpenExpressApp/Tool/UITest/Ruby/dll'
require "Microsoft.VisualStudio.TestTools.UITest.Extension.dll"
require "Microsoft.VisualStudio.TestTools.UITest.Extension.IE.dll"
require "Microsoft.VisualStudio.TestTools.UITest.Extension.IE.Communication.Interop.dll"
require "Microsoft.VisualStudio.TestTools.UITest.Extension.MSAA.dll"
require "Microsoft.VisualStudio.TestTools.UITest.Extension.Uia.dll"
require "Microsoft.VisualStudio.TestTools.UITest.Framework.dll"
require "Microsoft.VisualStudio.TestTools.UITesting.dll"
require "Microsoft.VisualStudio.TestTools.UITest.Playback.dll"
require "Microsoft.VisualStudio.TestTools.UITesting.dll"
include Microsoft::VisualStudio::TestTools::UITesting
class TestApplication
attr_accessor :app
attr_accessor :modules
def initialize()
Playback.Initialize()
end
def Run(path="", userName="", password="")
if (path == "")
path = 'd:\GZJ\OpenExpressApp\OpenExpressApp.Host.WPF\bin\Debug\OpenExpressApp.Host.WPF.exe'
end
app = ApplicationUnderTest.launch(path)
#new LoginDialog().Login(userName, password);
puts "太激动了,程序跑起来了"
end
end
app = TestApplication.new
app.Run()
$LOAD_PATH << 'D:/GZJ/OpenExpressApp/Tool/UITest/Ruby/dll'
require "Microsoft.VisualStudio.TestTools.UITest.Extension.dll"
require "Microsoft.VisualStudio.TestTools.UITest.Extension.IE.dll"
require "Microsoft.VisualStudio.TestTools.UITest.Extension.IE.Communication.Interop.dll"
require "Microsoft.VisualStudio.TestTools.UITest.Extension.MSAA.dll"
require "Microsoft.VisualStudio.TestTools.UITest.Extension.Uia.dll"
require "Microsoft.VisualStudio.TestTools.UITest.Framework.dll"
require "Microsoft.VisualStudio.TestTools.UITesting.dll"
require "Microsoft.VisualStudio.TestTools.UITest.Playback.dll"
require "Microsoft.VisualStudio.TestTools.UITesting.dll"
include Microsoft::VisualStudio::TestTools::UITesting
class TestApplication
attr_accessor :app
attr_accessor :modules
def initialize()
Playback.Initialize()
end
def Run(path="", userName="", password="")
if (path == "")
path = 'd:\GZJ\OpenExpressApp\OpenExpressApp.Host.WPF\bin\Debug\OpenExpressApp.Host.WPF.exe'
end
app = ApplicationUnderTest.launch(path)
#new LoginDialog().Login(userName, password);
puts "太激动了,程序跑起来了"
end
end
app = TestApplication.new
app.Run()
打开VS项目,选择ir.exe
设置项目属性
在Arguments中填写-D path,不要忘记加-D了
F5运行调试
虽然这样可以进行调试,但是功能有限,不知VS什么时候能够支持一下IronRuby呢!
本文转自 jingen_zhou 51CTO博客,原文链接:http://blog.51cto.com/zhoujg/518041,如需转载请自行联系原作者