JMeter+Ant-自动发送测试结果报告邮件

JMeter+Ant-⾃动发送测试结果报告邮件l⽂件
将这三个jar包(activation.jar、commons-email-1.2.jar、mail.jar)放到ant下的lib下
(我的是:/usr/local/Cellar/ant/1.10.5/libexec/lib)
<?xml version="1.0" encoding="UTF8"?>
<project name="ant-jmeter-test" default="run" basedir=".">
<property name="jmeterPath" value="/Applications/apache-jmeter-4.0"/>
<property name="mailhost" value="smtp.163"/>
<property name="username" value="jiangpr_ok@163"/>螺旋桨设计
<property name="password" value="输⼊163邮箱等密码"/>
<property name="mailfrom" value="jiangpr_ok@163"/>
<property name="mail_to" value="591379035@qq,931410265@qq"/>
<property name="mailsubject" value="XX系统接⼝⾃动化测试报告"/>
<property name="mail_port" value="25"/>
<property name="message" value="Hi!请查收下,这是XX接⼝⾃动化测试报告,如有任何疑问,请联系我,谢谢!"/>
<tstamp>
<format property="time" pattern="yyyyMMddhhmm"/>
</tstamp>
<property name="jmeter.home" value="${jmeterPath}"/>
<property name="sult.jtl.dir" value="${jmeterPath}\test\report\jtl"/>
<property name="sult.html.dir" value="${jmeterPath}\test\report\html"/>
<property name="htmlReportNameSummary" value="TestReport"/>
<property name="sult.jtlName" value="${sult.jtl.dir}/${htmlReportNameSummary}${time}.jtl"/>
<property name="sult.htmlName" value="${sult.html.dir}/${htmlReportNameSummary}${time}.html"/>
<target name="run">
历史虚无主义<antcall target="test"/>
<antcall target="report"/>
<antcall target="sendEmail"/>
</target>
<!--执⾏接⼝测试-->
<target name="test">
<echo>执⾏接⼝⾃动化测试</echo>
<taskdef name="jmeter" classname="org.programmerplanet.ant.taskdefs.jmeter.JMeterTask"/>
<jmeter jmeterhome="${jmeter.home}" resultlog="${sult.jtlName}">
<!--要执⾏的测试脚本-->
<testplans dir="${jmeterPath}\test\script" includes="测试计划.jmx"/>
<property name="jmeter.save.saveservice.output_format" value="xml"/>
</jmeter>
</target>
<!--解决报告中NAN字段显⽰问题-->
<path id="xslt.classpath">
<fileset dir="${jmeter.home}/lib" includes="xalan-2.7.2.jar"/>
<fileset dir="${jmeter.home}/lib" includes="serializer-2.7.2.jar"/>
</path>
<!--⽣成HTML测试报告-->
<target name="report">
<echo>⽣成接⼝⾃动测试报告</echo>
<xslt classpathref="xslt.classpath"
force="true"
in="${sult.jtlName}" out="${sult.htmlName}"
/>
<!--复制图⽚-->
<copy todir="${sult.html.dir}">
<fileset dir="${jmeter.home}/extras">
<include name="collapse.png"/>
<include name="expand.png"/>
</fileset>
</copy>
</target>
<!--⾃动发送邮件-->
<target name="sendEmail">
<echo>发送⾃动化测试报告</echo>
<mail mailhost="${mailhost}"
ssl="ture"
user="${username}"
password="${password}"
mailport="${mail_port}"
subject="${mailsubject}"
messagemimetype="text/html"
tolist="${mail_to}">
<from address="${mailfrom}"/>
<attachments>
<fileset dir="${sult.html.dir}">
<include name="${htmlReportNameSummary}${time}.html"/>
<include name="collapse.png"/>
<include name="expand.png"/>
</fileset>
</attachments>
<message>
${message}
</message>
</mail>
</target>
</project>
执⾏
(base) localhost:test ligaijiang$ cd /Applications/apache-jmeter-4.0/test
道州论坛(base) localhost:test ligaijiang$ ant
Buildfile: /Applications/apache-jmeter-4.0/l
(base) localhost:test ligaijiang$ cd /Applications/apache-jmeter-4.0/test
(base) localhost:test ligaijiang$ ant
Buildfile: /Applications/apache-jmeter-4.0/l
run:
test:
[echo] 执⾏接⼝⾃动化测试
[jmeter] Executing test plan: /Applications/apache-jmeter-4.0/test/script/测试计划.jmx ==> /Applications/apache-jmeter-4.0/test/report/jtl/TestReport201904270811.jtl
高粱秸
[jmeter] WARNING: An illegal reflective access operation has occurred
[jmeter] WARNING: Illegal reflective access by com.util.Fields (file:/Applications/apache-jmeter-4.0/lib/xstream-1.4.10.jar) to field java.util.TreeMapparator    [j
meter] WARNING: Please consider reporting this to the maintainers of com.util.Fields
[jmeter] WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
雅克141
[jmeter] WARNING: All illegal access operations will be denied in a future release
[jmeter] Creating summariser <summary>
[jmeter] Created the tree successfully using /Applications/apache-jmeter-4.0/test/script/测试计划.jmx
[jmeter] Starting the test @ Sat Apr 27 20:11:43 CST 2019 (1556367103226)
[jmeter] Waiting for possible Shutdown/StopTestNow/Heapdump message on port 4445
[jmeter] summary +    46 in 00:00:17 =    2.8/s Avg:  354 Min:    72 Max:  2209 Err:    0 (0.00%) Active: 1 Started: 1 Finished: 0
[jmeter] summary +    30 in 00:00:12 =    2.6/s Avg:  387 Min:    64 Max:  4197 Err:    8 (26.67%) Active: 0 Started: 1 Finished: 1
[jmeter] summary =    76 in 00:00:28 =    2.7/s Avg:  367 Min:    64 Max:  4197 Err:    8 (10.53%)
[jmeter] Tidying up ...    @ Sat Apr 27 20:12:11 CST 2019 (1556367131829)
[jmeter] ... end of run
report:
[echo] ⽣成接⼝⾃动测试报告
[xslt] Processing /Applications/apache-jmeter-4.0/test/report/jtl/TestReport201904270811.jtl to /Applications/apache-jmeter-4.0/test/report/html/TestReport201904270811.html
[xslt] Loading stylesheet /Applications/apache-jmeter-4.0/extras/jmeter-results-detail-report_21.xsl
sendEmail:
[echo] 发送⾃动化测试报告
[mail] Sending email: XX系统接⼝⾃动化测试报告
小文件存储
[mail] Sent email with 3 attachments
BUILD SUCCESSFUL
Total time: 33 seconds
(base) localhost:test ligaijiang$

本文发布于:2024-09-23 11:22:20,感谢您对本站的认可!

本文链接:https://www.17tex.com/xueshu/124369.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:动化   发送   测试报告
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2024 Comsenz Inc.Powered by © 易纺专利技术学习网 豫ICP备2022007602号 豫公网安备41160202000603 站长QQ:729038198 关于我们 投诉建议