antcall

<project name="test-antcall" default="run-tests" basedir=".">
    <!-- check os -->
    <target name="os">
        <!-- if os is unix, the value of is.unix is true -->
        <condition property="is.unix">
            <os family="unix"/>
        </condition>
        <!-- if os is windows, the value of is.windows is true -->
        <condition property="is.windows">
            <os family="windows"/>
        </condition>
        
        <echo>
            os.name=${os.name}
            os.arch=${os.arch}
            os.version=${os.version}
            
            is.unix=${is.unix}
            is.windows=${is.windows}
        </echo>
    </target>
    
    <!-- =================================
          target: test-on-windows              
         ================================= -->
    <target name="test-on-windows" depends="os" if="is.windows"
        description="testing on windows">
        <echo>Running tests on windows</echo>
    </target>

    <!-- =================================
          target: test-on-linux              
         ================================= -->
    <target name="test-on-linux" depends="os" if="is.linux"
        description="testing on linux">
        <echo>Running tests on linux</echo>
    </target>

    <!-- - - - - - - - - - - - - - - - - -
          target: run-tests                      
         - - - - - - - - - - - - - - - - - -->
    <target name="run-tests">
        <antcall target="test-on-windows"/>
        <antcall target="test-on-linux"/>
    </target>
    
</project>

<?xml version="1.0" encoding="UTF-8"?> <project name="ant-jmeter-test" default="all" basedir="."> <tstamp> <format property="time" pattern="yyyyMMddhhmm" /> </tstamp> <!-- 需要改成自己本地的 Jmeter 目录--> <property name="jmeter.home" value="D:\jmeter\apache-jmeter-5.2.1"/> <!-- jmeter生成jtl格式的结果报告的路径--> <property name="jmeter.result.jtl.dir" value="D:\jenkins\test_auto\workspace\reports\jtl"/> <!-- jmeter生成html格式的结果报告的路径--> <property name="jmeter.result.html.dir" value="D:\jenkins\test_auto\workspace\reports\html"/> <!-- 生成的报告的前缀--> <property name="ReportName" value="TestReport" /> <property name="jmeter.result.jtlName" value="${jmeter.result.jtl.dir}/${ReportName}${time}.jtl" /> <property name="jmeter.result.htmlName" value="${jmeter.result.html.dir}/${ReportName}${time}.html" /> <target name="all"> <antcall target="test" /> <antcall target="report" /> </target> <target name="test"> <taskdef name="jmeter" classname="org.programmerplanet.ant.taskdefs.jmeter.JMeterTask" /> <jmeter jmeterhome="${jmeter.home}" resultlog="${jmeter.result.jtlName}"> <!-- 声明要运行的脚本。"*.jmx"指包含此目录下的所有jmeter脚本--> <testplans dir="D:\jenkins\test_auto\workspace\testCases" includes="*.jmx" /> <!-- 增加如下一行代码,否则会报错误,经测试使用jmeter3.0版本不增加下面一行代码不会报告错误--> <property name="jmeter.save.saveservice.output_format" value="xml"/> </jmeter> </target> <!-- html报告中时间显示为NAN,原因是ant中缺失了两个lib库 xalan-2.7.2.jar和serializer-2.7.2.jar ,将这两个库拷贝到ant的lib目录下,或者在这里增加如下代码均可解决--> <path id="xslt.classpath"> <fileset dir="${jmeter.home}/lib" includes="xalan*.jar"/> <fileset dir="${jmeter.home}/lib" includes="serializer*.jar"/> </path> <!-- html报告中Date report这里的时间没有正确显示出来,原因是未设定report.datestamp 属性值--> <target name="report"> <tstamp> <format property="report.datestamp" pattern="yyyy/MM/dd HH:mm" /></tstamp> <xslt in="${jmeter.result.jtlName}" out="${jmeter.result.htmlName}" style="${jmeter.home}/extras/jmeter-results-detail-report_21.xsl" /> <!-- 因为上面生成报告的时候,不会将相关的图片也一起拷贝至目标目录,所以,需要手动拷贝 --> <copy todir="${jmeter.result.html.dir}"> <fileset dir="${jmeter.home}/extras"> <include name="collapse.png" /> <include name="expand.png" /> </fileset> </copy> </target> </project> 读取testcase里面的text.jmx,ant文件已经放置好了
07-16
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值