我可以在 QTP 中引用另一个函数库吗
我想在 QTP 中的另一个函数库中引用一个函数。
这是编程基础知识,但阅读 QTP 帮助,看起来一切都必须通过“测试”层访问,这意味着编写实用程序函数,例如日期处理程序。
I want to reference a function from one Function Library in another in QTP.
This is programming basics but reading QTP help, it looks like everything has to be accessed through the 'Test' layer which means that writing utility functions such as date handlers.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您确实可以在动作脚本中编写函数。 您不必编写函数库来编写和使用自定义函数。为了可重用性,函数库很有意义。
您可以在一个函数库中放入任意数量的函数。
如果函数库相互依赖,您应该确保在测试设置中以正确的顺序引用它们。
VBScript 中有一个 ExecuteGlobal 语句,它允许您指定包含函数定义的(巨大)字符串。 使用这样的字符串执行 ExecuteGlobal 将声明所有这些函数。这是(除了 ExecuteGlobal 的姊妹函数,如 ExecuteFile(或者它叫什么?))使用函数库的唯一真正替代方案。
You can indeed write functions in action scripts. You do not have to write function libraries to write and use custom functions. For reusability, function libraries make sense.
You can put as many functions into one function library as you wish.
Should you want to create more than one function library, you simply add them all to the resources settings of each test.
If function libraries depend on each other, you should make sure to reference them in the correct order in the test settings.
There is an
ExecuteGlobal
statement in VBScript which would allow you to specify a (huge) string containing function definitions. Executing ExecuteGlobal with such a string would declare all those functions. This is (besides ExecuteGlobal's sister functions, like ExecuteFile (or what was it called?)) the only real alternative to using function libraries.