jmeter中配置node.js/ ant
ant环境配置
1.下载ant安装包
2.解压(非C盘)路径
3.配置环境变量 我的电脑-右击 、属性-左击 、高级系统设置-环境变量 用户变量中新建ANT-HOME 配置自己的路径(D:\jmeter\test\ant\apache-ant-1.9.14),path中添加路径(D:\jmeter\test\ant\apache-ant-1.9.14\bin)。系统变量中同样配置path路径。
4.cmd 输入 anr -v 进行验证 显示版本号代表成功。
node环境配置:
1.下载安装包;
2.无脑下一步(路径建议非c盘)
3.cmd 输入node -v 验证 显示版本号代表成功。
builder文件配置(横线标注地方,需要根据自己电脑/账号进行个人配置)
<?xml version="1.0" encoding="utf-8"?>
<!-- builder.xml文件所在路径 -->
<project name="pc" default="all" basedir="D:\jmeter\build.xml">
-------------------------------------------------------------------
<tstamp>
<format property="time" pattern="yyyyMMddhhmm" />
</tstamp>
<!-- 需要改成自己本地的 Jmeter 目录-->
<property name="jmeter.home" value=:D:\jmeter\apache-jmeter-5.3" />
---------------------------------------------------------------------
<!-- jmeter生成jtl格式的结果报告的路径-->
<property name="jmeter.result.jtl.dir" value="D:\jmeter\test\textauto\pc\resultlog\jtl" />
-------------------------------------------------------------------------------------------
<!-- jmeter生成html格式的结果报告的路径-->
<property name="jmeter.result.html.dir" value="D:\jmeter\test\textauto\pc\resultlog\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" />
<!-- 接收测试报告的邮箱 -->
<property name="mail_from" value="930957144@qq.com" />
------------------------------------------------------
<property name="mail_to" value="930957144@qq.com" />
------------------------------------------------------
<!-- 电脑地址 -->
<!-- <property name="ComputerName" value="DESKTOP-3M84A32" />-->
-----------------------------------------------------------------
<target name="all">
<antcall target="test" />
<antcall target="report" />
<antcall target="send" />
</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:\jmeter\test\textauto\pc\script" />
-----------------------------------------------------------
</jmeter>
</target>
<path id="xslt.classpath">
<fileset dir="${jmeter.home}/lib" includes="xalan*.jar"/>
<fileset dir="${jmeter.home}/lib" includes="serializer*.jar"/>
</path>
<target name="report">
<xslt
classpathref="xslt.classpath"
force="true"
in="${jmeter.result.jtlName}"
out="${jmeter.result.htmlName}"
style="${jmeter.home}/extras/jmeter-results-detail-report_21.xsl">
<param name="dateReport" expression="${time}"/>
</xslt>
<!-- 因为上面生成报告的时候,不会将相关的图片也一起拷贝至目标目录,所以,需要手动拷贝 -->
<copy todir="${jmeter.result.html.dir}">
<fileset dir="${jmeter.home}/extras">
<include name="collapse.png" />
<include name="expand.png" />
</fileset>
</copy>
</target>
<!-- 发送邮件 -->
<target name="send" >
<mail mailhost="smtp.qq.com" mailport="587" subject="Test Report!" messagemimetype="text/html" user="930957144@qq.com" password="qowubmkfkkfibcjc" >
-----------------------------------------------------------------------------------------------------------------------------------------------------
<from address="${mail_from}"/>
<to address="${mail_to}"/>
<message>This email was sent automatically by ANT. Please check the automation test report. Thank you!</message>
<attachments>
<fileset dir="${jmeter.result.html.dir}">
<include name="${ReportName}${time}.html"/>
<include name="${ReportName}${time}.html"/>
</fileset>
</attachments>
</mail>
</target>
</project>