使用ANT动态调用soapui的属性文件
我使用ApacheAnt设置jenkins作业来触发SOAPUIAPI自动化套件。 我希望在运行套件之前,应该首先调用外部属性文件并加载属性 Build.xml:使用ANT动态调用soapui的属性文件,ant,soapui,Ant,Soapui,我使用ApacheAnt设置jenkins作业来触发SOAPUIAPI自动化套件。 我希望在运行套件之前,应该首先调用外部属性文件并加载属性 Build.xml: <project name="soapUI Nightly Build" default="testreport" basedir="."> <target name ="soapui"> <exec dir="." executable="C:/IntegerationAPI/APIPack
<project name="soapUI Nightly Build" default="testreport" basedir=".">
<target name ="soapui">
<exec dir="." executable="C:/IntegerationAPI/APIPackage/SoftwareRequired/SoapUI/SoapUI-5.2.1/bin/testrunner.bat">
<arg line="-j -f 'C:/Program Files (x86)/Jenkins/workspace/IntegerationAPI-2' 'C:/IntegerationAPI/APIPackage/SOAP_Script/VisitorSearchAPI-soapui-project.xml'"/>
</exec>
</target>
<target name ="testreport" depends ="soapui">
<junitreport todir="C:/Program Files (x86)/Jenkins/workspace/IntegerationAPI-2">
<fileset dir="C:/Program Files (x86)/Jenkins/workspace/IntegerationAPI-2">
<include name="TEST-*.xml"/>
</fileset>
<report todir="C:/Program Files (x86)/Jenkins/workspace/IntegerationAPI-2/HTML"
styledir="C:/apache-ant-1.9.6-bin/apache-ant-1.9.6/etc"
format="noframes">
</report>
</junitreport>
</target>
</project>
如何做到这一点?您需要做的就是将如下所示的jvm参数传递给testrunner命令 在项目级别加载外部属性文件的步骤 -Dsoapui.properties= 在测试套件级别加载外部属性文件 -Dsoapui.properties= 针对您的情况,将以下内容添加到现有的testrunner命令中:
-Dsoapui.properties.VisitorSearch_API=C:/IntegerationAPI/APIPackage/Property_Files/VisitorSearchProperties.Properties
您可以如下更改soapui
目标,注意arg
元素开头的更改
<target name ="soapui">
<exec dir="C:/IntegerationAPI/APIPackage/SoftwareRequired/SoapUI/SoapUI-5.2.1/bin" executable="testrunner.bat">
<arg line="-Dsoapui.properties.VisitorSearch_API=C:/IntegerationAPI/APIPackage/Property_Files/VisitorSearchProperties.Properties -j -f 'C:/Program Files (x86)/Jenkins/workspace/IntegerationAPI-2' 'C:/IntegerationAPI/APIPackage/SOAP_Script/VisitorSearchAPI-soapui-project.xml'"/>
</exec>
</target>
我不懂,但是你不能使用Ant吗?你需要在哪里加载它?在build.xml
中?还是soapui项目/套件?在脚本开头使用
任务有什么问题?您说过希望动态加载,但没有指出它的哪个部分需要动态加载,或者以什么方式加载。脚本中的所有其他文件路径都是硬编码的,所以为什么它们没有类似的问题呢?我不知道哪种方法是正确的,因为我是新手……我知道这有两种方式。无论何时soapui运行,它都应该首先从外部文件加载属性。这样,当ANT调用soapui时,它会自动使用更新的属性运行。对吗?@rAJ,您需要在什么级别将属性加载到soapui项目?到项目级?或者任何特定的套件级别?
仍然得到相同的结果。新参数对结果没有影响。我的项目xml已经具有这些属性。它没有覆盖现有参数。您是否可以先在命令行上使用testrunner实用程序进行尝试?顺便问一下,你怎么知道它是否是覆盖的?你在哪里写日志?您介意显示日志吗?我运行这个C:\integrationapi\APIPackage\SoftwareRequiC:\Windows\system32>C:\integrationapi\APIPackage\SoftwareRequired\SoapUI\SoapUI-5.2.1\bin\testrunner.bat-j-f'C:/Program Files(x86)/Jenkins/workspace/Intege-rationAPI-2''C:/integrationapi/appackage/SOAP\u Script/VersionInformation-soapu I-project.xml'“
而输出是缺少SoapUI项目文件。
。输出的html报告文件总是相同的,这就是为什么我说它没有使用新属性,而是使用xml文件中的旧属性。@rAJ,您的命令不正确。转到目录SOAPUI_HOME/bin
;使用实际路径。然后运行testrunner.bat-Dsoapui.properties.VisitorSearch_API=C:/IntegerationAPI/APIPackage/Property_Files/VisitorSearchProperties.properties-j-f“C:/Program Files(x86)/Jenkins/workspace/Intege-rationAPI-2“C:/IntegerationAPI/appackage/SOAP_脚本/versioninformationn-soapu i-project.xml消息仍然是一样的:-C:\integrationapi\APIPackage\SoftwareRequired\SoapUI\SoapUI-5.2.1\bin>C:\integrate-rationAPI\APIPackage\SoftwareRequired\SoapUI\SoapUI-5.2.1\bin\testrunner.bat-j-f'C:/程序文件(x86)/Jenkins/workspace/integrationAPI-2''C:/integrationAPI/APIPackage/SOAP_Script/VersionInformation soapui project.xml'
<target name ="soapui">
<exec dir="C:/IntegerationAPI/APIPackage/SoftwareRequired/SoapUI/SoapUI-5.2.1/bin" executable="testrunner.bat">
<arg line="-Dsoapui.properties.VisitorSearch_API=C:/IntegerationAPI/APIPackage/Property_Files/VisitorSearchProperties.Properties -j -f 'C:/Program Files (x86)/Jenkins/workspace/IntegerationAPI-2' 'C:/IntegerationAPI/APIPackage/SOAP_Script/VisitorSearchAPI-soapui-project.xml'"/>
</exec>
</target>