soapui中的testrunner.bat调研姿势,用于自动化测试
副标题:soapui基于持续集成工具自动化运行的调研姿势
各位亲爱的同仁们,大家好吗?
最近项目在搞持续集成工具,我们的测试用例都是基于soapui工具(webservice restful)。
持续集成工具我们使的是jenkins。
我们需要使用工具来自动更新项目代码->自动构建->自动发布->自动RUN测试用例->自动发邮件等等功能。
jenkins支持用户添加运行bat文件来执行用户想让他执行的各种需求。
(其实其他的持续集成工具也都大同小异)
因此我们使用bat文件来调用soapui的testrunner.bat文件来达成这一需求!!!
以下为具体实现步骤:
0.首先请下载最新版本的soupui-pro,记住不要破解版,soupui-pro可以生成详细的测试结果文档,
而普通版本的soupui则没有此功能,并且更有趣的是,soupui官方竟然允许用户通过命令调用testrunner.bat
在用户没有购买license的情况下。(不好意思,英语写多了。)
官方地址为:http://www.soapui.org/,自己去下吧,亲。
1.下载完成后安装soupui-pro,之后你甚至都不用去运行soapui-pro。
假设你的安装目录在:C:Program FilesSmartBearsoapUI-Pro-4.5.1in
2.编写一个bat文件,内容如下:
@Echo Off
CD
C:
CD C:Program FilesSmartBearsoapUI-Pro-4.5.1in
testrunner.bat -r -j D:251Test-soapui-project.xml -f c: emp
eports -FPDF
之后运行这个bat即可。
3.下面来详细说明这个bat文件
首先我需要进入soapui-pro的安装目录,其目的是要以命令的方式去运行testrunner.bat文件。
(什么?你不知道这个文件是做什么的?好吧他是用来RUN测试用例的工具)
之后调用testrunner.bat,并在其后加入若干个参数。
关于testrunner.bat:
soapUI提供了一个命令行工具testrunner.bat来运行一个项目中的TestSuit,可以在<soap_ui_home>/bin下找到它,
它的使用非常简单,只需要设置下面的几个常用参数即可:
-s 指定要运行的 TestSuite
-f 指定运行结果的输出目录
-j 生成 junit 风格的 report
-r 运行完成以后打印一个简单的 summary
下面这行命令就是运行251Test-soapui-project.xml这个soapUI项目中的PushPoiTestSuite,
把结果输出到c: emp
eports中。
testrunner.bat -s PushPoiTestSuite -r -j D:251Test-soapui-project.xml -f c: emp
eports
如果我想运行xml里的所有测试用例怎么办?好说,删掉-s PushPoiTestSuite即可。
testrunner.bat -r -j D:251Test-soapui-project.xml -f c: emp
eports -FPDF
为什么我要加上一个-FPDF呢?这是pro的特性之一,可以将测试结果生成html,试想一下没有html展现是多么恐怖的事情!
自动运行结束后,c: emp
eports目录中会有运行结果以及一个index.html,打开他!
以下为其余的参数(请原谅我没有翻译成中文)
e : The endpoint to use when invoking test-requests, overrides the endpoint set in the project file
h : The host:port to use when invoking test-requests, overrides only the host part of the endpoint set in the project file
s : The TestSuite to run, used to narrow down the tests to run
c : The TestCase to run, used to narrow down the tests to run
u : The username to use in any authentications, overrides any username set for any TestRequests
p : The password to use in any authentications, overrides any password set for any TestRequests
w : Sets the WSS password type, either 'Text' or 'Digest'
d : The domain to use in any authentications, overrides any domain set for any TestRequests
r : Turns on printing of a small summary report (see below)
f : Specifies the root folder to which test results should be exported (see below)
j : Turns on exporting of JUnit-compatible reports, see below
a : Turns on exporting of all test results, not only errors
o : Opens the generated report in a browser (SoapUI Pro only)
i : Enables SoapUI UI-related components, required if you use the UISupport class for prompting or displaying information
t : Sets the soapui-settings.xml file to use, required if you have custom proxy, ssl, http, etc setting
x : Sets project password for decryption if project is encrypted
v : Sets password for soapui-settings.xml file
D : Sets system property with name=value
G : Sets global property with name=value
P : Sets project property with name=value, e.g. -Pendpoint=Value1 -PsomeOtherProperty=value2
S : Sets to save the project file after tests have been run
I : Do not stop if error occurs, ignore them
R : Selects which report to generate for the test objects executed, for example if running the entire project, this could specify the name of a test-suite-level report that would be generated for each TestSuite. The report is saved as specified with the -F option to the folder specified with the -f option. (SoapUI Pro only)
F : Sets the format of the report specified with the -R option, for Printable reports this is one of PDF, XLS, HTML, RTF, CSV, TXT, and XML. For Data Export this is either XML or CSV (SoapUI Pro only)
g : Sets the output to include Coverage HTML reports ( SoapUI Pro only )
E : Sets which environment to use (SoapUI Pro only)
官方说明传送门:http://www.soapui.org/Test-Automation/functional-tests.html
SoapUI命令行方式运行 http://blog.csdn.net/hunterno4/article/details/38425077