QTP DotNetFactory 与 COM 可见的 .NET 程序集
我只是好奇 - QTP 具有直接通过 DotNetFactory 对象调用 .NET 对象的功能,请参阅 这篇文章来自learnqtp.com,不过它也可以通过COM调用对象(参见这篇文章来自乔·科兰托尼奥)。使用一种方法相对于另一种方法有什么优势?据我所知,这两种方法对可调用的对象都有类似的限制(没有带参数的构造函数等),但我想知道更深入的细节。
谢谢!
I'm just curious - QTP has the functionality to call .NET objects directly via the DotNetFactory object, see this article from learnqtp.com, but it can also call objects through COM (see this post from Joe Colantonio). What would the advantage be in using one method over another? So far as I can tell, both methods have similar restrictions on the objects that can be called (no constructors with parameters, etc.), but I'm wondering about deeper details.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,您的一个假设是错误的,
DotNetFactory
确实支持使用参数调用构造函数(这就是可选的args
参数的用途)。CreateObject
函数内置于 VBScript,因为 QTP 测试是用 VBScript 编写的,此功能是免费的,从技术上讲并不是 QTP 功能。DotNetFactory
是 QTP 的一部分,允许创建 .NET 对象,即使它们不是 COM 可见的。如果您有一个 COM 可见的 .NET 对象,您可以选择您更喜欢的方法,但如果您有一个 COM 对象,则必须使用
CreateObject
,如果您有一个非 COM 可见对象您必须使用DotNetFactory。First of all one of your assumptions is wrong,
DotNetFactory
does support calling constructors with parameters (that's what the optionalargs
parameter is for).The
CreateObject
function is built in for VBScript, since QTP tests are written in VBScript this functionality comes for free and is not technically a QTP feature. TheDotNetFactory
is part of QTP and allows creating .NET objects even if they are not COM visible.If you have a .NET object which is COM visible you can choose which method you're more comfortable with but if you have a COM object you must use
CreateObject
and if you have a non-COM visible object you must useDotNetFactory
.