4、在本地任意创建目录testcases(如:D:testcases) , 并在其目录下创建report文件夹和build.xml文件 , 复制以下内容到build.xml文件中:
<?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=https://www.isolves.com/it/cxkf/bk/2020-09-09/"D:Apachejmeter" />
<property name="report.title" value=https://www.isolves.com/it/cxkf/bk/2020-09-09/"测试报告" />
<!-- jmeter生成jtl格式的结果报告的路径 -->
<property name="jmeter.result.jtl.dir" value=https://www.isolves.com/it/cxkf/bk/2020-09-09/"D:testcasesreport" />
<!-- jmeter生成html格式的结果报告的路径 -->
<property name="jmeter.result.html.dir" value=https://www.isolves.com/it/cxkf/bk/2020-09-09/"D:testcasesreport" />
<!-- zip文件路径 -->
<property name="zip.dir" value=https://www.isolves.com/it/cxkf/bk/2020-09-09/"D:testcases" />
<!-- 生成的报告的前缀 -->
<property name="ReportName" value=https://www.isolves.com/it/cxkf/bk/2020-09-09/"testcases" />
<!-- 报告名称 -->
<property name="jmeter.result.jtlName" value=https://www.isolves.com/it/cxkf/bk/2020-09-09/"${jmeter.result.jtl.dir}/${ReportName}${time}.jtl" />
<property name="jmeter.result.htmlName" value=https://www.isolves.com/it/cxkf/bk/2020-09-09/"${jmeter.result.html.dir}/${ReportName}${time}.html" />
<property name="zipname" value=https://www.isolves.com/it/cxkf/bk/2020-09-09/"${zip.dir}/${ReportName}${time}.zip" />
<!-- 邮件配置信息 -->
<property name="mail_host" value=https://www.isolves.com/it/cxkf/bk/2020-09-09/"smtp.163.com" />
<property name="mail_port" value=https://www.isolves.com/it/cxkf/bk/2020-09-09/"465" />
<property name="username" value=https://www.isolves.com/it/cxkf/bk/2020-09-09/"testcases@163.com" />
<property name="password" value=https://www.isolves.com/it/cxkf/bk/2020-09-09/"123456789" />
<property name="mail_from" value=https://www.isolves.com/it/cxkf/bk/2020-09-09/"dtestcases@163.com" />
<property name="mail_to" value=https://www.isolves.com/it/cxkf/bk/2020-09-09/"testcases@163.com,testcases2@163.com" />
<property name="mailsubject" value=https://www.isolves.com/it/cxkf/bk/2020-09-09/"测试报告" />
<!-- 输出生成的报告名称和存放路径 -->
<echo message="${jmeter.result.jtlName}" />
<echo message="${jmeter.result.htmlName}" />
<echo message="${jmeter.result.html.dir}" />
<echo message="${zip.dir}" />
<echo message="${zipname}" />
<!-- 加载jar包 , 解决时间显示问题 -->
<path id="xslt.classpath">
<fileset dir="${jmeter.home}/lib" includes="xalan*.jar" />
<fileset dir="${jmeter.home}/lib" includes="serializer*.jar" />
</path>
<target name="all">
<antcall target="test" />
<antcall target="report" />
<antcall target="summary-report" />
<antcall target="zip" />
<!-- 打包zip -->
<antcall target="sendEmail" />
<!-- 发送邮件 -->
</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 将需要执行的jmx写在includes中 -->
<testplans dir="D:testcases" includes="*.jmx" />
<property name="jmeter.save.saveservice.output_format" value=https://www.isolves.com/it/cxkf/bk/2020-09-09/"xml" />
<!-- 这里就是jmeter.properties修改的部分 -->
</jmeter>
</target>
<target name="report">
<tstamp>
<format property="report.datestamp" pattern="yyyy/MM/dd HH:mm" />
</tstamp>
<xslt classpathref=https://www.isolves.com/it/cxkf/bk/2020-09-09/"xslt.classpath" force="true" in="${jmeter.result.jtlName}" out="${jmeter.result.html.dir}/summary-report.html" style="${jmeter.home}/extras/jmeter.results.shanhe.me.xsl">
推荐阅读
- Docker-For-Pentest的渗透测试镜像推荐
- Java JMH 基准测试工具
- httpClient 请求接口如何优雅的重试
- 三层架构下,优酷视频搜索测试体系很复杂吗?
- 智能手机|苹果iPhone也得改 欧盟进一步投票推动USBC统一手机接口
- USB接口3.2,usb3.0接口可以接3.1?
- 从模拟接口到8K传输 显卡接口这些年变得太多
- Web渗透测试——验证码自动识别工具
- 使用 HTTPie 进行 API 测试
- iPhone|iPhone 14曝光 接口大升级:苹果逼你买Pro版 独享USB 3.0