zoukankan      html  css  js  c++  java
  • 【ANT】运行JMeter用例的build.xml

      1 <?xml version="1.0" encoding="UTF-8"?>
      2 <!--
      3    Licensed to the Apache Software Foundation (ASF) under one or more
      4    contributor license agreements.  See the NOTICE file distributed with
      5    this work for additional information regarding copyright ownership.
      6    The ASF licenses this file to You under the Apache License, Version 2.0
      7    (the "License"); you may not use this file except in compliance with
      8    the License.  You may obtain a copy of the License at
      9     
     10        http://www.apache.org/licenses/LICENSE-2.0
     11     
     12    Unless required by applicable law or agreed to in writing, software
     13    distributed under the License is distributed on an "AS IS" BASIS,
     14    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     15    See the License for the specific language governing permissions and
     16    limitations under the License.
     17 -->
     18 <project name="ant-jmeter" default="all">
     19     <description>
     20 
     21         Sample build file for use with ant-jmeter.jar
     22         See http://www.programmerplanet.org/pages/projects/jmeter-ant-task.php
     23 
     24     To run a test and create the output report:
     25         ant -Dtest=script
     26 
     27     To run a test only:
     28         ant -Dtest=script run
     29 
     30     To run report on existing test output
     31         ant -Dtest=script report
     32 
     33     The "script" parameter is the name of the script without the .jmx suffix.
     34 
     35     Additional options:
     36         -Dshow-data=y - include response data in Failure Details
     37         -Dtestpath=xyz - path to test file(s) (default user.dir).
     38                          N.B. Ant interprets relative paths against the build file
     39         -Djmeter.home=.. - path to JMeter home directory (defaults to parent of this build file)
     40         -Dreport.title="My Report" - title for html report (default is 'Load Test Results')
     41 
     42         Deprecated:
     43         -Dformat=2.0 - use version 2.0 JTL files rather than 2.1
     44 
     45     </description>
     46     <property name="testpath" value="${basedir}"/>
     47     <property name="jmeter.home" value="${basedir}/../../jmeter-3.0"/>
     48     <property name="report.title" value="测试报告"/>
     49      <property name="ReportName" value="DIY" />
     50     
     51      <tstamp>
     52         <format property="time" pattern="yyyyMMddhhmm" />
     53     </tstamp>
     54     
     55     <!-- Should report include response data for failures? -->
     56     <property name="show-data" value="n"/>
     57 
     58     <property name="format" value="2.1"/>
     59     
     60     <condition property="style_version" value="">
     61         <equals arg1="${format}" arg2="2.0"/>
     62     </condition>
     63 
     64     <condition property="style_version" value="_21">
     65         <equals arg1="${format}" arg2="2.1"/>
     66     </condition>
     67 
     68     <condition property="funcMode">
     69         <equals arg1="${show-data}" arg2="y"/>
     70     </condition>
     71     
     72     <condition property="funcMode" value="false">
     73       <not>
     74         <equals arg1="${show-data}" arg2="y"/>
     75       </not>
     76     </condition>
     77 
     78     <!-- Allow jar to be picked up locally -->
     79     <path id="jmeter.classpath">
     80         <fileset dir="${jmeter.home}/extras">
     81           <include name="ant-jmeter*.jar"/>
     82         </fileset>
     83     </path>
     84 
     85     <taskdef
     86         name="jmeter"
     87         classpathref="jmeter.classpath"
     88         classname="org.programmerplanet.ant.taskdefs.jmeter.JMeterTask"/>
     89     
     90     <target name="all" depends="run,report"/>
     91 
     92     <target name="run">
     93         <echo>funcMode = ${funcMode}</echo>
     94         <delete verbose="true" includeemptydirs="true">
     95             <fileset dir="${testpath}/htmls">
     96                 <include name="**/*"/>
     97             </fileset>
     98         </delete>
     99         <delete verbose="true" includeemptydirs="true">
    100             <fileset dir="${testpath}/jtls">
    101                 <include name="**/*"/>
    102             </fileset>
    103         </delete>
    104 
    105        <!-- <delete file="${testpath}/htmls/*.html"/>
    106         <delete file="${testpath}/jtls/*.jtl"/>
    107          -->
    108         <jmeter
    109             jmeterhome="${jmeter.home}"
    110             resultlog="${testpath}/jtls/${ReportName}.jtl">
    111               <!--  testplan ="${testpath}/jmxs/Test.jmx"-->
    112         <!--
    113             <jvmarg value="-Xincgc"/>
    114             <jvmarg value="-Xmx128m"/>
    115             <jvmarg value="-Dproperty=value"/>
    116             <jmeterarg value="-qextra.properties"/>
    117         -->
    118             <!-- Force suitable defaults -->
    119             <jvmarg value="-Dfile.encoding=UTF-8"/>
    120             <testplans dir="${testpath}/jmxs" includes="*.jmx" />
    121             <property name="jmeter.save.saveservice.response_data" value="false"/>
    122             <property name="jmeter.save.saveservice.samplerData" value="true"/>
    123             <property name="jmeter.save.saveservice.responseHeaders" value="true"/>
    124             <property name="jmeter.save.saveservice.requestHeaders" value="true"/>
    125             <property name="jmeter.save.saveservice.encoding" value="true"/>
    126             <property name="jmeter.save.saveservice.url" value="true"/>
    127             <property name="jmeter.save.saveservice.filename" value="true"/>
    128             <property name="jmeter.save.saveservice.hostname" value="true"/>
    129             <property name="jmeter.save.saveservice.thread_counts" value="true"/>
    130             <property name="jmeter.save.saveservice.sample_count" value="true"/>
    131             <property name="jmeter.save.saveservice.idle_time" value="true"/>
    132             <property name="jmeter.save.saveservice.output_format" value="xml"/>
    133             <property name="jmeter.save.saveservice.assertion_results" value="all"/>
    134             <property name="jmeter.save.saveservice.bytes" value="true"/>
    135             <property name="file_format.testlog" value="${format}"/>
    136             <property name="jmeter.save.saveservice.response_data.on_error" value="true"/>
    137         </jmeter>
    138     </target>
    139 
    140     <property name="lib.dir" value="${jmeter.home}/lib"/>
    141 
    142     <!-- Use xalan copy from JMeter lib directory to ensure consistent processing with Java 1.4+ -->
    143     <path id="xslt.classpath">
    144         <fileset dir="${jmeter.home}/lib" includes="xalan*.jar"/>
    145         <fileset dir="${jmeter.home}/lib" includes="serializer*.jar"/>
    146     </path>
    147 
    148     <target name="report" depends="xslt-report,copy-images">
    149         <echo>Report generated at ${report.datestamp}</echo>
    150     </target>
    151 
    152     <target name="xslt-report" depends="_message_xalan">
    153         <tstamp><format property="report.datestamp" pattern="yyyy/MM/dd HH:mm"/></tstamp>
    154         <xslt
    155             classpathref="xslt.classpath"
    156             force="true"
    157             in="${testpath}/jtls/${ReportName}.jtl"
    158             out="${testpath}/htmls/${ReportName}.html"
    159             style="${jmeter.home}/extras/jmeter.results.shanhe.me.xsl">
    160             <param name="showData" expression="${show-data}"/>
    161             <param name="titleReport" expression="${report.title}"/>
    162             <param name="dateReport" expression="${report.datestamp}"/>
    163         </xslt>
    164     </target>
    165 
    166     <!-- Copy report images if needed -->
    167     <target name="copy-images" depends="verify-images" unless="samepath">
    168         <copy file="${basedir}/expand.png" tofile="${testpath}/htmls/expand.png"/>
    169         <copy file="${basedir}/collapse.png" tofile="${testpath}/htmls/collapse.png"/>
    170     </target>
    171 
    172     <target name="verify-images">
    173         <condition property="samepath">
    174                 <equals arg1="${testpath}" arg2="${basedir}" />
    175         </condition>
    176     </target>
    177 
    178     <!-- Check that the xalan libraries are present -->
    179     <condition property="xalan.present">
    180           <and>
    181               <!-- No need to check all jars; just check a few -->
    182             <available classpathref="xslt.classpath" classname="org.apache.xalan.processor.TransformerFactoryImpl"/>
    183             <available classpathref="xslt.classpath" classname="org.apache.xml.serializer.ExtendedContentHandler"/>
    184           </and>
    185     </condition>
    186 
    187     <target name="_message_xalan" unless="xalan.present">
    188           <echo>Cannot find all xalan and/or serialiser jars</echo>
    189         <echo>The XSLT formatting may not work correctly.</echo>
    190         <echo>Check you have xalan and serializer jars in ${lib.dir}</echo>
    191     </target>
    192 
    193 
    194 </project>
    build.xml

    相关目录及文件:

  • 相关阅读:
    [原创] 扩展jquery-treegrid插件, 实现勾选功能和全删按钮.
    [原创]多版本Java环境变量的配置
    [转]Redmine 配置163邮箱
    [转] --- Error: “A field or property with the name was not found on the selected data source” get only on server
    服务器控件中使用<%#...>, JS和html控件中使用<%=...>
    【字源大挪移—读书笔记】 第三部分:字尾
    【字源大挪移—读书笔记】 第二部分:字根
    使用WebClient 或者 HttpWebRequest均报:"The Remote name can't be solved"
    【字源大挪移—读书笔记】 第一部分:字首
    【英语魔法俱乐部——读书笔记】 3 高级句型-简化从句&倒装句(Reduced Clauses、Inverted Sentences) 【完结】
  • 原文地址:https://www.cnblogs.com/xiongjiawei/p/6542919.html
Copyright © 2011-2022 走看看