build.xml文件

将这三个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.com"/>
<property name="username" value="jiangpr_ok@163.com"/>
<property name="password" value="输入163邮箱等密码"/>
<property name="mailfrom" value="jiangpr_ok@163.com"/>
<property name="mail_to" value="591379035@qq.com,931410265@qq.com"/>
<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="jmeter.result.jtl.dir" value="${jmeterPath}\test\report\jtl" />
<property name="jmeter.result.html.dir" value="${jmeterPath}\test\report\html" />
<property name="htmlReportNameSummary" value="TestReport" />
<property name="jmeter.result.jtlName" value="${jmeter.result.jtl.dir}/${htmlReportNameSummary}${time}.jtl" />
<property name="jmeter.result.htmlName" value="${jmeter.result.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="${jmeter.result.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="${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>
<!--自动发送邮件-->
<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="${jmeter.result.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/test/build.xml
(base) localhost:test ligaijiang$ cd /Applications/apache-jmeter-4.0/test

(base) localhost:test ligaijiang$ ant
Buildfile: /Applications/apache-jmeter-4.0/test/build.xml 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.thoughtworks.xstream.core.util.Fields (file:/Applications/apache-jmeter-4.0/lib/xstream-1.4.10.jar) to field java.util.TreeMap.comparator
[jmeter] WARNING: Please consider reporting this to the maintainers of com.thoughtworks.xstream.core.util.Fields
[jmeter] WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
[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$

JMeter+Ant-自动发送测试结果报告邮件的更多相关文章

  1. jmeter+ant+jenkins生产的报告乱码

    jmeter+ant+jenkins生产的报告乱码 问题:生产报告会乱码的问题,一般是有编码格式引起的.我遇到的问题是,jmeter需要读取csv的数据作为参数.但是我们并不知道csv保存是什么编码格 ...

  2. window 下 jmeter+ant 自动生成html报告并发送邮件

    一.安装ant 1.ant 下载地址:https://ant.apache.org/bindownload.cgi 2.下载完成解压到指定目录下 3.配置ant 环境变量 新建系统变量 -ANT_HO ...

  3. Jmeter+ant+Jenkins实现接口自动化平台及报告发送

    项目中实现了比较方便的自动化体系,一直没时间总结一下,现抽空整理一番,废话不多说  内容如下: 一.环境准备  jmeter : 编写接口脚本,实现接口测试 ant  :静默执行jmeter脚本,并生 ...

  4. ant+jmeter+jenkins+git持续集成以及邮件报告展示

    前序准备工作: ant--下载地址:http://ant.apache.org/bindownload.cgi jmeter--下载地址:http://jmeter.apache.org/downlo ...

  5. Jenkins+Jmeter+Ant自动化集成及邮件正文以html输出

    一.工具的安装与环境变量配置 1.依次安装Jenkins+Jmeter+Ant,具体安装步骤,此文不再详述 2.配置Jmeter&ant环境变量 Jmeter变量: 验证是否配置成功:cmd窗 ...

  6. jmeter+ant+jenkins+mac报告优化

    一.在上篇博客中生成的报告有两个问题: 1.date not defined 2.Min Time和Max Time显示成了NaN 二.Jmeter+Ant报告生成原理: 在解决问题之前,让我们先弄清 ...

  7. 转:利用ant与jmeter实现负载测试自动化

    性能测试一直以来都是测试领域一个令人争议的话题.测试的参考标准.评判依据及测试的方法选择都很难有一个统一的说法.但无论如何,对于需要能够承受一定压力而运行的程序来说,进行其进行功能和性能测试是一个必不 ...

  8. Jmeter + Ant 测试环境搭建 及解决问题: the <jmeter> type doesn't support nested text data

    1.首先确保测试机器中已经按照jdk1.6以上版本,如果没有,那就上官网下载吧. 2.下载Ant,解压至指定目录,并配置好环境变量:http://ant.apache.org/ 在命令行下执行ant ...

  9. jmeter+ant+jenkins+mac报告优化(一):解决Min Time和Max Time显示NaN

    一.在上篇博客中生成的报告有两个问题: 1.date not defined 2.Min Time和Max Time显示成了NaN 二.Jmeter+Ant报告生成原理: 1.在Jmeter的extr ...

随机推荐

  1. iOS开发多线程之NSOperation

    NSInvocationOperation The NSInvocationOperationclass is a concrete subclass of NSOperationthat you u ...

  2. 使用mysqlslap进行MySQL压力测试

    使用mysqlslap进行MySQL压力测试发表于236 天前 ? MySQL ? 暂无评论 MySQL从5.1.4版开始带有一个压力测试工具mysqlslap,通过模拟多个并发客户端访问mysql来 ...

  3. pip错误-failed to create process/fatal error in launcher

    电脑同时装了python2和python3,并且都配置了环境变量 将python2的python.exe改成python2.exe,python3的python.exe没有改(主要用python2时则 ...

  4. phpstorm对laravel的一些使用技巧

    安装laravel插件,设置ctrl+alt+s 二 安装智能提示插件 composer require barryvdh/laravel-ide-helper 在config/app.php的pro ...

  5. 利用反射获取数据列+emit生成属性+单例模式

    1:IDictionary<string,string > 可以存储数据,将拼接的sql可以存储到这里下次可以使用 定义自定义属性表和列 typeof(T).GetCustomAttrib ...

  6. linux 添加ssh和开启ssh服务apt管理的ubuntu

    是在ubuntu下出现的需求 现笔记记录 apt-get  update 更新源命令 apt-get  install  openssh-server 安装ssh服务 容易出现无法定位软件包.出现此问 ...

  7. python 几个简单算法详解

    一.冒泡排序 基本思想:它的思路很有特点循环,两两向后比较.它重复地走访过要排序的数列,一次比较两个元素,如果他们的顺序错误就把他们交换过来.走访数列的工作是重复地进行直到没有再需要交换,也就是说该数 ...

  8. [Python]Python中的浅复制与深复制

    看python的文档,发现list有copy方法,描述说效果同a[:]. 感觉有点惊讶,之前一直以为a[:]执行的是深复制. test了一下,发现确实如果a中存在可变对象,如list/set/dict ...

  9. Java_比较两个图片的相似度

    说明:目前使用像素偏移量为5,可根据实际情况相应修改 package com.creditease.fetch.credit.util.similarity; import com.crediteas ...

  10. vue学习:vue+webpack的快速使用指南(新手向)

    一.vue有两种使用方式: 1.下载vue.js <script src="vue.js"></script> 2.使用npm npm install vu ...