增加更加详细测试报告及优化jenkins测试报告样式显示
1、下载优化模板 jmeter-results-shanhe-me.xsl,拷贝到jmeter的C:\jmeter\apache-jmeter-5.0\extras目录中
2、设置测试输出报告要输出的内容:同样在jmeter.properties中,设置需要输出的内容为true,并去掉前面的注释符号#,这里全部设置成true→保存
jmeter.save.saveservice.data_type=true
jmeter.save.saveservice.label=true
jmeter.save.saveservice.response_code=true
# response_data is not currently supported for CSV output
jmeter.save.saveservice.response_data=true
# Save ResponseData for failed samples
jmeter.save.saveservice.response_data.on_error=false
jmeter.save.saveservice.response_message=true
jmeter.save.saveservice.successful=true
jmeter.save.saveservice.thread_name=true
jmeter.save.saveservice.time=true
jmeter.save.saveservice.subresults=true
jmeter.save.saveservice.assertions=true
jmeter.save.saveservice.latency=true
# Only available with HttpClient4
jmeter.save.saveservice.connect_time=true
jmeter.save.saveservice.samplerData=true
jmeter.save.saveservice.responseHeaders=true
jmeter.save.saveservice.requestHeaders=true
jmeter.save.saveservice.encoding=true
jmeter.save.saveservice.bytes=true
# Only available with HttpClient4
#jmeter.save.saveservice.sent_bytes=true
jmeter.save.saveservice.url=true
jmeter.save.saveservice.filename=true
jmeter.save.saveservice.hostname=true
jmeter.save.saveservice.thread_counts=true
jmeter.save.saveservice.sample_count=true
jmeter.save.saveservice.idle_time=true
3、如果两种报告都要,设置build文件的报告模板为汇总报告和详情报告
汇总报告
style="${jmeter.home}/extras/jmeter-results-detail-report_21.xsl" >
详细报告
style="${jmeter.home}/extras/jmeter.results.shanhe.me.xsl" >
4、因为要展示两种报告,build新增内容如下
<?xml version="1.0" encoding="utf-8"?><!-- 名称 -->
<project name="uncleyong_jmeter_test" default="all" basedir="."><tstamp><format property="time" pattern="yyyyMMdd_hhmmss" /></tstamp><!-- 需要改成自己本地的 Jmeter 目录--><property name="jmeter.home" value="C:\jmeter\apache-jmeter-5.0" /><!-- jmeter生成jtl格式的结果报告的路径--><property name="jmeter.result.jtl.dir" value="C:\jmeter\apache-jmeter-5.0\jmeter_ant_jenkins\result\jtl" /><!-- jmeter生成html格式的结果报告的路径--><property name="jmeter.result.html.dir" value="C:\jmeter\apache-jmeter-5.0\jmeter_ant_jenkins\result\html" /><property name="jmeter.result.html.dir1" value="C:\jmeter\apache-jmeter-5.0\jmeter_ant_jenkins\result\html1" /><!-- 生成的报告的前缀 --><property name="ReportName" value="result_" /><property name="ReportName1" value="result_1" /><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="jmeter.result.htmlName1" value="${jmeter.result.html.dir1}/${ReportName}${time}.html" /><!-- 电脑地址 --><property name="ComputerName" value="jmeter_ant_jenkins" /><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="C:\jmeter\apache-jmeter-5.0\jmeter_ant_jenkins\jmeter_script" includes="*.jmx" /><property name="jmeter.save.saveservice.output_format" value="xml"/></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"><tstamp><format property="report.datestamp" pattern="yyyy/MM/dd HH:mm"/></tstamp><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="${report.datestamp}"/></xslt><xslt classpathref="xslt.classpath" force="true" in="${jmeter.result.jtlName}" out="${jmeter.result.htmlName1}" style="${jmeter.home}/extras/jmeter.results.shanhe.me.xsl" ><param name="dateReport" expression="${report.datestamp}"/></xslt><copy todir="${jmeter.result.html.dir}"><fileset dir="${jmeter.home}/extras"><include name="collapse.png" /><include name="expand.png" /></fileset></copy></target>
</project>
5、存放测试报告目录如下
uncleyong jmeter路径下
--jmeter_script 存放jmeter脚本 .jmx
--result
--html 存放生成的html测试报告概要
--html1 存放生成的html详细测试报告
--jtl 存放生成的jtl测试报告
build.xml build文件
6、jenkins配置-构建后操作新增如下
7、jenkins构建成功控制台输出
8、详细测试报告
9、解决jenkins html测试报告显示样式问题
Manage Jenkins—Script Console中输入System.setProperty("hudson.model.DirectoryBrowserSupport.CSP","") 点右下角运行
10、jenkins再次构建成功,查看汇总测试报告和详细测试报告,样式显示已正常