• Jmeter Ant Task如果报告中有错误,在邮件内容里面直接显示出来 系列1


    ANT调用的XML文件,包括运行脚本、生成报告、发送邮件:

    <?xml version="1.0"?>
    <project name="morningstar" default="all" basedir=".">
    	<property name="JMeter.home" value="......."/>
    	<property name="mail_to" value="test.hu@qq.com,test.li@qq.com,test.bai@163.com"/>
    	<property name="to_me_only" value="test.zhang@163.com"/>	
    	<tstamp>
    		<format property="time" pattern="yyyyMMddhhmm"/>
    	</tstamp>
    	<target name="all" >
    		<antcall target="runClient"/>
    		<antcall target="transferAll"/>
    		<antcall target="transferFailure"/>
    		<antcall target="sendEmail"/>
    	</target>
    	<target name="runClient" depends="">
    		<taskdef name="jmeter" classname="org.programmerplanet.ant.taskdefs.jmeter.JMeterTask"/>
    		<jmeter jmeterhome="${JMeter.home}" resultlog="${basedir}/Result/CIMAutoTestReport${time}.jtl">
    			<testplans dir="${basedir}ScriptSmokeTest" includes="CIM_ClientProspect_SmokeTest_TP.jmx"/>
    		</jmeter>
    	</target>
    	<target name = "transferAll" depends = "">
    		<xslt in="${basedir}/Result/CIMAutoTestReport${time}.jtl" 
    			out="${JMeter.home}/extras/CIMAutoTestReport${time}.html" 
    			style="${JMeter.home}/extras/JMeter-results-detail-report_21.xsl"/>
    	</target>
    	<target name = "transferFailure" depends = "">
    		<xslt in="${basedir}/Result/CIMAutoTestReport${time}.jtl" 
    			out="${JMeter.home}/extras/CIMAutoTestReport${time}_failure.html" 
    			style="${JMeter.home}/extras/JMeter-results-detail-report_21_failure.xsl"/>
    	</target>
    	<target name="sendEmail">
    		<mail mailhost="internalmail.test.com" mailport="25" subject="CIM SmokeTest Report!" messagefile="${JMeter.home}/extras/CIMAutoTestReport${time}_failure.html" messagemimetype="text/html" tolist="${mail_to}">
    			<from address="jenny.zhang@test.com"/>
    			<fileset dir="${JMeter.home}/extras/">
    				<!-- <include name="CIMAutoTestReport${time}.html"/> -->
    				<include name="expand.png"/>
    			</fileset>
    			<!-- <message>This email was sent automatically by ANT. <br />
    			Please check the automation test report by the link below.  <br />
    			If there are any questions, please contact with Jenny Zhang. Thank you! <br /><br />
    			http://SZCOMPUTER/CIMAutoTestReport${time}.html
    			</message> -->
    		</mail>
    	</target>
    </project>
    

     其次,在D:apache-jmeter-2.7extras目录复制一份jmeter-results-detail-report_21.xsl,将其命名为jmeter-results-detail-report_21_failure.xsl,修改两个地方,一个是154行左右的地方:

    <xsl:template name="summary">
        <h2>Test Report Link</h2>
        <h2>http://SZOTWIN2K801/CIMAutoTestReport${time}.html</h2>
        <h2>Summary</h2>

    添加了两行:

        <h2>Test Report Link</h2>
        <h2>http://SZOTWIN2K801/CIMAutoTestReport${time}.html</h2>

    另外一个地方是大概230行左右的地方,改成下面这样:

    <xsl:for-each select="/testResults/*[attribute::s='false']">

    原来是这样的:

    <xsl:for-each select="/testResults/*[not(@lb = preceding::*/@lb)]">

    这样运行之后,如果有失败的,发出来的邮件就会是这样的:

    如果全部成功,发出来的邮件就会是这样的:

  • 相关阅读:
    编译duilib遇到问题:Error C2371 "IDispatchEx重定义;不同的基类型"
    初尝DirectUI
    ms-onlinetest-question02
    ms-onlinetest-question3
    都是申请空间后不赋初值惹的祸..
    CString接受返回的char*字符串后成为乱码
    CL.exe @C:Users upAppDataLocalTemp mpc8fc399365e34f739eff6191a0c9acde.rsp”。存储控制块地址无效
    Visual Studio Ultimate 2012 静态激活密钥
    如何写入和获取软件的版本信息(VS环境下)
    mt.exe : general error c101008a: Failed to save the updated manifest to the file "DebugResource.dll.embed.manifest". Bpo
  • 原文地址:https://www.cnblogs.com/MasterMonkInTemple/p/3375979.html
Copyright © 2020-2023  润新知