简体   繁体   English

如何从命令行编译和运行QTP脚本

[英]How to compile and run QTP script from command line

I want to use a text file containing the source code of the QTP script, and compile it (create the usr,cfg,usp etc files that get created when we manually "save" a script in QTP) by using the command line. 我想使用一个包含QTP脚本源代码的文本文件,并使用命令行对其进行编译(创建当我们在QTP中手动“保存”脚本时创建的usr,cfg,usp等文件)。 Is there a way to do both? 有办法做到这两者吗?

All those extra files in QTP/UFT are for when you're doing "more" than just writing a script. QTP / UFT中所有这些额外的文件都是为您做“更多”而不仅仅是编写脚本的。 It stores the test description, associated repositories, parameters, recovery scenarios, etc. If you're writing test logic in a text file, there's a good chance you're not using any of that extra stuff either. 它存储测试描述,关联的存储库,参数,恢复方案等。如果您在文本文件中编写测试逻辑,则很有可能您也不会使用任何这些多余的东西。

Take any blank QTP/UFT test to create a "template" of a valid test. 进行任何空白的QTP / UFT测试,以创建有效测试的“模板”。 Then all you have to do is replace the 'Action1/script.mts' file with the contents of your text file. 然后,您要做的就是用文本文件的内容替换“ Action1 / script.mts”文件。

If you want do to all of this from a command-line, you'll need to write a simple console-based application to do the heavy lifting for you. 如果要从命令行执行所有这些操作,则需要编写一个基于控制台的简单应用程序来为您完成繁重的工作。

To get rid of the problem, I´d make sure that run results never are saved in the test´s directory, and apply SVN on the whole directory of a test, or to the whole "tests" subdirectory root . 为了解决该问题,我将确保运行结果永远不会保存在test的目录中,并且将SVN应用于测试的整个目录或整个“ tests”子目录的根目录

This might result in quite some subdirectory structure, but it has a meaning (for QTP), and without run results, it´s not hundreds of files, or megabytes, so SVN can indeed chew on them quite well. 这可能会导致相当多的子目录结构,但是(对于QTP)它具有含义,并且没有运行结果,它不是数百个文件或兆字节,因此SVN确实可以很好地咀嚼它们。

Alternatively, you could use QC to save your tests in a QC repo, and enable version control in it. 另外,您可以使用QC将测试保存在QC存储库中,并在其中启用版本控制。 Then, QC will handle the "bundling" of all files of a tests, and guarantee that only one user can modify a given test. 然后,质量控制将处理测试的所有文件的“捆绑”,并保证只有一个用户可以修改给定的测试。

Point is, if you just put the script into SVN, and, when you need it, re-create the other files programmatically, you lose info like (not limited to): 关键是,如果只是将脚本放入SVN中,并且在需要时以编程方式重新创建其他文件,则会丢失信息,例如(但不限于):

  • data table name, tab structure, content local repository content 数据表名称,选项卡结构,内容本地存储库内容
  • associated repository file(s) 关联的存储库文件
  • associated library file(s) run settings 关联的库文件运行设置
  • ActiveScreen screens expected values for checkpoints ActiveScreen筛选检查点的期望值
  • Action properties 动作属性
  • Action parameters (formal and actual) 动作参数(正式和实际)
  • Action call hierarchy (test flow) 动作调用层次结构(测试流程)
  • Subactions´ script content 子操作的脚本内容

which probably is unacceptable except for the simplest most trivial tests. 除了最简单的最简单的测试之外,这可能是不可接受的。 So I recommend you drop the idea of just saving the script content. 因此,我建议您放弃仅保存脚本内容的想法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM