我可以从 QTP 测试/调用 Java 服务吗?如何?
3 回答
您可以查看用于测试“非基于 GUI 的服务”的 QTP 服务测试插件。
You can also test directly from VBScript in QTP, without the Service Test add-in. See this SQAForums post.
To call the jar file:
To call the jar file, you can use QTP’s SystemUtil.Run like this:
SystemUtil.Run “cmd”,”/c java -jar parsingclass.jar”,””</p>
To call the java class:
For a java class you would do something like this:
SystemUtil.Run “cmd”,”/K java D:\HL7Parser\bin\CORUExtractorFlow1151.class”,””</p>
Explanation About the Code:
SystemUtil Object is a QTP object that can be used to control an application or process during a test run.
The Run method runs a file or application. cmd starts a new instance of a command interpreter.
/K is a parameter that runs the command and leaves the command window open. (If you want to close the command window instead of keeping it open, you would need to replace the /K parameters with the /C parameter.) For more info on CMD and its parameters, check out Microsoft’s documentation website
For move complicate Java calls
If you have a more complicated Java DLL that you need to interact with, you could use Service Test 11, which contains a call java class activity. With a “Unified Functional license ,” you could call Service Test from QTP; in our case, however, this would have been overkill, so we kept it simple by using the method described above.