使用ANT动态调用属性文件到soapui

时间:2017-09-11 11:31:28

标签: ant soapui

我设置jenkins作业以使用Apache ANT触发SoapUI API自动化套件。 我想在运行套件之前,首先调用外部属性文件并加载属性。

Build.xml:

<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>

属性文件路径:

C:\IntegerationAPI\APIPackage\Property_Files\VisitorSearchProperties.Properties

如何做到这一点?

1 个答案:

答案 0 :(得分:1)

您需要做的就是将jvm参数传递给test runner命令。

在项目级别加载外部属性文件 -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>