Empty Ant <junitreport> report for SoapUI testrunner XML results

一笑奈何 提交于 2019-12-24 09:16:32

问题


I am running a SoapUI project using Ant to get a JUnit report.

Here is my build.xml:

<project basedir="." default="testreport" name="APIAutomation">
<target name="SoapUI">
    <exec dir="." executable="C:\Program Files (x86)\SmartBear\SoapUI-5.0.0\bin\testrunner.bat">
        <arg line="-r -j -a -f 'C:\Users\F3020722\Desktop\Notification\New folder' -sFirstLoginTest 'C:\Users\F3020722\Desktop\Notification\New folder\APIRegression.xml'"></arg>
    </exec>
</target>
<target name="testreport" depends="SoapUI">
    <junitreport todir="C:\Users\F3020722\Desktop\Notification\New folder\API">
        <fileset dir="C:\Users\F3020722\Desktop\Notification\New folder\API">
            <include name="TEST-*.xml"/>
        </fileset>
        <report format="frames"
            todir="C:\Users\F3020722\Desktop\Notification\New folder\reports\html">
        </report>
    </junitreport>
</target>
</project>

I am getting an XML report properly. However, the JUnit report is empty. all contains 0 and successrate is Nan.

Can anyone check the build.xml is correct?


回答1:


  • Looks build script seems ok
  • Avoid spaces in the directory names
  • Use forward slashes like unix style even on windows
  • Use property file or properties in build script so that other members do not have it edit the build scripts as paths might change machine to machine.
  • For now, added properties in the below script, you may externalize to a property file too.

build.xml

<project basedir="." default="testreport" name="APIAutomation">
   <property name="test.suite" value="FirstLoginTest"/>
   <property name="soapui.project" value="C:/Users/F3020722/Desktop/Notification/New folder/APIRegression.xml"/>
   <property name="soapui.home" value="C:/Program Files (x86)/SmartBear/SoapUI-5.0.0"/>
   <property name="results.dir" value="C:/Users/F3020722/Desktop/Notification/API/Results"/>
   <property name="reports.dir" value="${results.dir}/Reports"/>
   <property name="html.dir" value="${reports.dir}/html"/>
   <target name="execute.project">
     <exec dir="${soapui.home}/bin" executable="testrunner.bat">
        <arg line="-raj -f ${results.dir} -s ${test.suite} ${soapui.project}" />
     </exec>
  </target>
   <target name="testreport" depends="execute.project">
        <mkdir dir="${reports.dir}"/>
            <junitreport todir="${reports.dir}">
                <fileset dir="${results.dir}">
                    <include name="TEST-*.xml"/>
                </fileset>
                <report format="frames" todir="${html.dir}" />
            </junitreport>
   </target>
</project>

You can also find a docker image for soapui and run tests & generate junit style html report as well. Refer soapui repository @ hub.docker.com

Note: that build script used docker images is exactly the same as above except the machine path.



来源:https://stackoverflow.com/questions/43117320/empty-ant-junitreport-report-for-soapui-testrunner-xml-results

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!