江苏中小企业网站建设,淘宝禁止了网站建设类,搭建论坛网站使用的系统,贵阳学校网站建设首先#xff0c;保证本地安装并部署了jenkins#xff0c;jmeter#xff0c;xslproc
我搭建的自动化测试框架是jmeterjenkinsxslproc
注意#xff1a;原理是#xff0c;jmeter自生成的报告jtl文件#xff0c;通过xslproc工具#xff0c;再结合jmeter自带的模板修改保证本地安装并部署了jenkinsjmeterxslproc
我搭建的自动化测试框架是jmeterjenkinsxslproc
注意原理是jmeter自生成的报告jtl文件通过xslproc工具再结合jmeter自带的模板修改自带模板目录如下最终将测试结果报告转化为html格式 在这我也准备了一份软件测试视频教程含接口、自动化、性能等需要的可以直接在下方观看或者直接关注VX公众号互联网杂货铺免费领取
软件测试视频教程观看处 京东内部员工自动化测试培训课程盲目自学真的会毁终生27天学完能救一个是一个... 1.jenkins新建一个任务,选择“构建一个自由风格的软件项目”点击OK 2.选择构建触发器根据时间点每天到点进行自动触发构建 3.输入构建命令 1D:/soft/apache-jmeter-3.2/bin/jmeter -n -t D:/soft/apache-jmeter-3.2/jmx/接口测试.jmx
这一句是通过cmd命令调用jmeter程序执行jmeter的jmx自动化脚本
2D:/soft/xsltproc/bin/xsltproc D:/soft/apache-jmeter-3.2/xsl/jmeter-results-detail-report_new.xsl %WORKSPACE%/test.jtl%WORKSPACE%/test.html
这一句是调用xslproc程序通过jmeter-results-detail-report_new.xsl模板将jtl文件转换为html报告文件
4. 邮件的格式代码如下
大家好本次接口测试构建结果如下
hr/!DOCTYPE html
html
head
meta namereferrer contentnever
title${ENV, varJOB_NAME}-第${BUILD_NUMBER}次构建日志/title
/headbody leftmargin8 marginwidth0 topmargin8 marginheight4 offset0table width95% cellpadding0 cellspacing0stylefont-size: 11pt; font-family: Tahoma, Arial, Helvetica, sans-seriftrtd(本邮件是程序自动下发的请勿回复)/td/trtrtdh2font color#0000FF构建结果 - ${BUILD_STATUS}/font/h2/td/trtrtdbr /bfont color#0B610B构建信息/font/bhr size2 width100% aligncenter //td/trtrtdulli项目名称nbsp;nbsp;${PROJECT_NAME}/lili构建编号nbsp;nbsp;第${BUILD_NUMBER}次构建/lili触发原因nbsp;${CAUSE}/lili构建日志nbsp;a href${BUILD_URL}console${BUILD_URL}console/a/lili构建nbsp;nbsp;Urlnbsp;nbsp;a href${BUILD_URL}${BUILD_URL}/a/lili工作目录nbsp;nbsp;a href${PROJECT_URL}ws${PROJECT_URL}ws/a/lili项目nbsp;nbsp;Urlnbsp;nbsp;a href${PROJECT_URL}${PROJECT_URL}/a/li/ul/td/trtrtdbfont color#0B610BChanges Since LastSuccessful Build:/font/bhr size2 width100% aligncenter //td/trtrtdulli历史变更记录 : a href${PROJECT_URL}changes${PROJECT_URL}changes/a/li/ul ${CHANGES_SINCE_LAST_SUCCESS,reversetrue, formatChanges for Build #%n:br /%cbr /,showPathstrue,changesFormatpre[%a]br /%m/pre,pathFormatnbsp;nbsp;nbsp;nbsp;%p}/td/trtrtdbFailed Test Results/bhr size2 width100% aligncenter //td/trtrtdprestylefont-size: 11pt; font-family: Tahoma, Arial, Helvetica, sans-serif$FAILED_TESTS/prebr //td/tr/table/body
/html
b${FILE,pathD:/jenkins/workspace/test/test.html}/b
以上是jenkins的所有设置
5.jenkins的版本太低的话可能存在需要手动下载jenkins插件 最后附上模板代码给各位
xsl:stylesheet xmlns:xslhttp://www.w3.org/1999/XSL/Transform version1.0!--Licensed to the Apache Software Foundation (ASF) under one or morecontributor license agreements. See the NOTICE file distributed withthis work for additional information regarding copyright ownership.The ASF licenses this file to You under the Apache License, Version 2.0(the License); you may not use this file except in compliance withthe License. You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an AS IS BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License.
--!-- Stylesheet for processing 2.1 output format test result files To uses this directly in a browser, add the following to the JTL file as line 2:?xml-stylesheet typetext/xsl href../extras/jmeter-results-detail-report_21.xsl?and you can then view the JTL in a browser
--xsl:output methodhtml indentyes encodingGB18030 doctype-public-//W3C//DTD HTML 4.01 Transitional//EN /!-- Defined parameters (overrideable) td bgcolor#ff00ff --
xsl:param nameshowData selecty/
xsl:param nametitleReport select接口测试/xsl:template matchtestResultshtml headtitlexsl:value-of select$titleReport //titlestyle typetext/cssbody {font:normal 95% verdana,arial,helvetica;color:#000000;}table tr td, table tr th {font-size: 95%;}table.details tr th{word-wrap:break-word;color: #ffffff;font-weight: bold;text-align:center;background:#2674a6;}table.details tr td{width: 400px;word-wrap:break-word;background:#eeeee0;}table{table-layout:fixed ; }h1 {margin: 0px 0px 5px; font: 165% verdana,arial,helvetica}h2 {margin-top: 1em; margin-bottom: 0.5em; font: bold 125% verdana,arial,helvetica}h3 {margin-bottom: 0.5em; font: bold 115% verdana,arial,helvetica}.Failure {font-weight:bold; color:red;}img{border-width: 0px;}.expand_link{position:absolute;right: 0px;width: 27px;top: 1px;height: 27px;}.page_details{display: none;}/* .page_details_expanded{display: block;displayhide this definition from IE5/6: table-row;} *//stylescript languageJavaScript![CDATA[function expand(details_id){document.getElementById(details_id).className page_details_expanded;}function collapse(details_id){document.getElementById(details_id).className page_details;}function change(details_id){if(document.getElementById(details_id_image).src.match(expand)){document.getElementById(details_id_image).src collapse.png;expand(details_id);}else{document.getElementById(details_id_image).src expand.png;collapse(details_id);} }]]/script/headbody xsl:call-template namepageHeader /xsl:call-template namemyresult / xsl:call-template namesummary /hr size1 width75% aligncenter /xsl:call-template namepagelist /hr size1 width75% aligncenter /xsl:call-template namedetail //body/html
/xsl:templatexsl:template namepageHeaderh1xsl:value-of select$titleReport //h1table width100%trtd alignleftDate report:/tdtd alignrightfrom 一卡通/td/tr/tablehr size1 /
/xsl:templatexsl:template namemyresultxsl:variable nameallFailCount selectcount(/testResults/*[attribute::sfalse]) /xsl:if test$allFailCount 0h2测试结果:成功/h2
/xsl:if
xsl:if test$allFailCount gt; 0h2 bgcolor#ff00ff测试结果:失败/h2h2 bgcolor#ff00ff失败个数:xsl:value-of selectcount(/testResults/*[attribute::sfalse])//h2/xsl:if /xsl:templatexsl:template namesummaryh2报告概况/h2table aligncenter classdetails border0 cellpadding5 cellspacing2 width95%tr valigntopth用例总数/thth失败数/thth成功率/thth平均响应时间/th/trtr valigntopxsl:variable nameallCount selectcount(/testResults/*) /xsl:variable nameallFailureCount selectcount(/testResults/*[attribute::sfalse]) /xsl:variable nameallSuccessCount selectcount(/testResults/*[attribute::strue]) /xsl:variable nameallSuccessPercent select$allSuccessCount div $allCount /xsl:variable nameallTotalTime selectsum(/testResults/*/t) /xsl:variable nameallAverageTime select$allTotalTime div $allCount /xsl:variable nameallMinTimexsl:call-template nameminxsl:with-param namenodes select/testResults/*/t //xsl:call-template/xsl:variablexsl:variable nameallMaxTimexsl:call-template namemaxxsl:with-param namenodes select/testResults/*/t //xsl:call-template/xsl:variablexsl:attribute nameclassxsl:choosexsl:when test$allFailureCount gt; 0Failure/xsl:when/xsl:choose/xsl:attributetd aligncenterxsl:value-of select$allCount //tdtd aligncenterxsl:value-of select$allFailureCount //tdtd aligncenterxsl:call-template namedisplay-percentxsl:with-param namevalue select$allSuccessPercent //xsl:call-template/tdtd aligncenterxsl:call-template namedisplay-timexsl:with-param namevalue select$allAverageTime //xsl:call-template/td/tr/table
/xsl:templatexsl:template namepagelisth2详细情况/h2table aligncenter classdetails border0 cellpadding5 cellspacing2 width95%tr valigntopth width50%功能模块/thth检查次数/thth失败数/thth成功率/thth平均响应时间/th/trxsl:for-each select/testResults/*[not(tn preceding::*/tn)]xsl:variable namelabel selecttn /xsl:variable namecount selectcount(../*[tn current()/tn]) /xsl:variable namefailureCount selectcount(../*[tn current()/tn][attribute::sfalse]) /xsl:variable namesuccessCount selectcount(../*[tn current()/tn][attribute::strue]) /xsl:variable namesuccessPercent select$successCount div $count /xsl:variable nametotalTime selectsum(../*[tn current()/tn]/t) /xsl:variable nameaverageTime select$totalTime div $count /xsl:variable nameminTimexsl:call-template nameminxsl:with-param namenodes select../*[tn current()/tn]/t //xsl:call-template/xsl:variablexsl:variable namemaxTimexsl:call-template namemaxxsl:with-param namenodes select../*[tn current()/tn]/t //xsl:call-template/xsl:variabletr valigntopxsl:attribute nameclassxsl:choosexsl:when test$failureCount gt; 0Failure/xsl:when/xsl:choose/xsl:attributetdxsl:if test$failureCount 0axsl:attribute namehref#xsl:value-of select$label //xsl:attributexsl:value-of select$label //a/xsl:ifxsl:if test0 $failureCountxsl:value-of select$label //xsl:if/tdtd aligncenterxsl:value-of select$count //tdtd aligncenterxsl:value-of select$failureCount //tdtd aligncenterxsl:call-template namedisplay-percentxsl:with-param namevalue select$successPercent //xsl:call-template/tdtd aligncenterxsl:call-template namedisplay-timexsl:with-param namevalue select$averageTime //xsl:call-template/td/tr/xsl:for-each/table
/xsl:templatexsl:template namedetailxsl:variable nameallFailureCount selectcount(/testResults/*[attribute::sfalse]) /xsl:if test$allFailureCount 0h2Failure Detail/h2xsl:for-each select/testResults/*[not(lb preceding::*/lb)] xsl:variable namefailureCount selectcount(../*[lb current()/lb][attribute::sfalse]) / xsl:if test$failureCount 0xsl:for-each select/testResults/*[lb current()/lb][attribute::sfalse] h3xsl:value-of selecttn /---xsl:value-of selectlb /axsl:attribute namenamexsl:value-of selecttn //xsl:attribute/a/h3table aligncenter classdetails border0 cellpadding5 cellspacing2 width95%tr valigntopthhttp请求/thth失败详细信息/thxsl:if test$showData yth响应数据/th/xsl:if/trtrtdxsl:value-of selectjava.net.URL / /tdtdxsl:value-of selectassertionResult/failureMessage //tdxsl:if test$showData ytdxsl:value-of selectresponseData //td/xsl:if/tr/table/xsl:for-each/xsl:if/xsl:for-each/xsl:if
/xsl:templatexsl:template nameminxsl:param namenodes select/.. /xsl:choosexsl:when testnot($nodes)NaN/xsl:whenxsl:otherwisexsl:for-each select$nodesxsl:sort data-typenumber /xsl:if testposition() 1xsl:value-of selectnumber(.) //xsl:if/xsl:for-each/xsl:otherwise/xsl:choose
/xsl:templatexsl:template namemaxxsl:param namenodes select/.. /xsl:choosexsl:when testnot($nodes)NaN/xsl:whenxsl:otherwisexsl:for-each select$nodesxsl:sort data-typenumber orderdescending /xsl:if testposition() 1xsl:value-of selectnumber(.) //xsl:if/xsl:for-each/xsl:otherwise/xsl:choose
/xsl:templatexsl:template namedisplay-percentxsl:param namevalue /xsl:value-of selectformat-number($value,0.00%) /
/xsl:templatexsl:template namedisplay-timexsl:param namevalue /xsl:value-of selectformat-number($value,0 ms) /
/xsl:template/xsl:stylesheet
模板的截图如下 写在最后
PS这套软件测试的自学教程合集对于在测试行业发展的小伙伴们来说应该会很有帮助。全套内容已经打包到网盘内容总量接近500个G。如需要软件测试学习资料关注公众号互联网杂货铺后台回复1整理不易给个关注点个赞吧谢谢各位大佬 这些资料对于做【软件测试】的朋友来说应该是最全面最完整的备战仓库这个仓库也陪伴我走过了最艰难的路程希望也能帮助到你凡事要趁早特别是技术行业一定要提升技术功底。