<?xml version="1.0"?>
<!--
   Licensed to the Apache Software Foundation (ASF) under one or more
   contributor license agreements.  See the NOTICE file distributed with
   this 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 with
   the License.  You may obtain a copy of the License at
    
       http://www.apache.org/licenses/LICENSE-2.0
    
   Unless required by applicable law or agreed to in writing, software
   distributed 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 and
   limitations under the License.
-->
<project name="ant-jmeter" default="all">
    <tstamp>
        <format property="time" pattern="yyyyMMddhhmm" />
    </tstamp>
    <description>

Sample build file for use with ant-jmeter.jar
        See http://www.programmerplanet.org/pages/projects/jmeter-ant-task.php

To run a test and create the output report:
        ant -Dtest=script

To run a test only:
        ant -Dtest=script run

To run report on existing test output
        ant -Dtest=script report

The "script" parameter is the name of the script without the .jmx suffix.

Additional options:
        -Dshow-data=y - include response data in Failure Details
        -Dtestpath=xyz - path to test file(s) (default user.dir).
                         N.B. Ant interprets relative paths against the build file
        -Djmeter.home=.. - path to JMeter home directory (defaults to parent of this build file)
        -Dreport.title="My Report" - title for html report (default is 'Load Test Results')
    </description>
    <!--user.dir 表示当前目录-->
    <property name="testpath" value="${user.dir}"/>
    <!--basedir 表示%jmeter_home% 地址-->
    <property name="jmeter.home" value="${basedir}/.."/>
    <!--测试报告的名字-->
    <property name="report.title" value="Load Test Results"/>
    
    <!-- Name of test (without .jmx) 定义测试,测试结果的名称-->
    <property name="test" value="Test"/>
    
    <!-- Should report include response data for failures? 测试报告中是否显示失败事务?value="n"表示不显示 -->
    <property name="show-data" value="n"/>
    <!--定义样式版本-->
    <property name="format" value="2.1"/>
    <!--定义jmeter脚本存放目录,指向%JMETER_HOME%/result-->
    <property name="jmeter.result" value="${jmeter.home}/result"/>
    <property name="script.dir" value="${jmeter.home}/script"/>
    <property name="jmeter.result.jtlName" value="${jmeter.home}/result/${test}${time}.jtl" />
    <property name="jmeter.result.htmlName" value="${jmeter.home}/result/${test}${time}.html" />
    <condition property="style_version" value="_21">
        <equals arg1="${format}" arg2="2.1"/>
    </condition>

<condition property="funcMode">
        <equals arg1="${show-data}" arg2="y"/>
    </condition>
    
    <condition property="funcMode" value="false">
      <not>
        <equals arg1="${show-data}" arg2="y"/>
      </not>
    </condition>

<!-- Allow jar to be picked up locally 定义依赖包-->
    <path id="jmeter.classpath">
        <!--这里的basedir 指的是 build.xml的目录-->
        <fileset dir="${basedir}">
            <!--把ant-jmeter开头的.jar包引入进来-->
          <include name="ant-jmeter*.jar"/>
        </fileset>
    </path>

<!--定义任务,即测试任务,依赖于ant-jmeter.jar-->
    <taskdef
        name="jmeter"
        classpathref="jmeter.classpath"
        classname="org.programmerplanet.ant.taskdefs.jmeter.JMeterTask"/>
    <!--定义任务,一个是run,即运行脚本,一个report,即生成报告-->
    <target name="all" depends="run,report"/>

<!--定义run-->
    <target name="run">
        <echo>funcMode = ${funcMode}</echo>
        <!--删除前一次测试报告,HTML格式的,${test}的变量值-->
<!--        <delete file="${jmeter.home}/result/${test}.html"/>-->
        <!--resultlog测试结果保存目录-->
        <jmeter
            jmeterhome="${jmeter.home}"
            resultlog="${jmeter.result.jtlName}">
            <!--指定测试脚本或者测试脚本所在目录-->
            <!--如果是单一脚本,名称是TestSentence1.jmx-->
            <testplans dir="${script.dir}" includes="TestSentence1.jmx"/>
        <!--
            <jvmarg value="-Xincgc"/>
            <jvmarg value="-Xmx128m"/>
            <jvmarg value="-Dproperty=value"/>
            <jmeterarg value="-qextra.properties"/>
        -->
            <!-- Force suitable defaults -->
            <!--暂且定义为xml格式,后续会变成文本格式-->
            <property name="jmeter.save.saveservice.output_format" value="xml"/>
            <property name="jmeter.save.saveservice.assertion_results" value="all"/>
            <property name="jmeter.save.saveservice.bytes" value="true"/>
            <property name="file_format.testlog" value="${format}"/>
            <!--是否定义错误信息,取决于${funcMode}-->
            <property name="jmeter.save.saveservice.response_data.on_error" value="${funcMode}"/>
        </jmeter>
    </target>

<!--定义依赖包目录-->
    <property name="lib.dir" value="${jmeter.home}/lib"/>

<!-- Use xalan copy from JMeter lib directory to ensure consistent processing with Java 1.4+ -->
    <path id="xslt.classpath">
        <fileset dir="${lib.dir}" includes="xalan*.jar"/>
        <fileset dir="${lib.dir}" includes="serializer*.jar"/>
    </path>

<!--定义report任务,此任务依赖于xslt-report,copy-images这两个任务-->
    <!--xslt-report作用:把xslt转换成html-->
    <!--copy-images作用:copy图片,xslt模板中图片由他来copy到目录-->
    <target name="report" depends="xslt-report,copy-images">
        <echo>Report generated at ${report.datestamp}</echo>
    </target>
    <!--_message_xalan被xslt-report依赖,由它生成报告-->
    <target name="xslt-report" depends="_message_xalan">
        <tstamp><format property="report.datestamp" pattern="yyyy/MM/dd HH:mm"/></tstamp>
        <!--in测试结果作为输入-->
        <!--style xstl模板地址-->
        <xslt
            classpathref="xslt.classpath"
            force="true"
            in="${jmeter.result.jtlName}"
            out="${jmeter.result.htmlName}"
            style="${basedir}/jmeter-results-detail-report${style_version}.xsl">
            <param name="showData" expression="${show-data}"/>
            <param name="titleReport" expression="${report.title}"/>
            <param name="dateReport" expression="${report.datestamp}"/>
        </xslt>
    </target>

<!-- Copy report images if needed 生成html报告需要拷贝图标到报告目录  expand.png展开图标,collapse.png收起图标-->
    <target name="copy-images" depends="verify-images" unless="samepath">
        <copy file="${basedir}/expand.png" tofile="${jmeter.home}/result/expand.png"/>
        <copy file="${basedir}/collapse.png" tofile="${jmeter.home}/result/collapse.png"/>
    </target>

<!--判断${testpath}和${basedir}是否是相同-->
    <target name="verify-images">
        <condition property="samepath">
                <equals arg1="${jmeter.home}" arg2="${basedir}" />
        </condition>
    </target>

<!-- Check that the xalan libraries are present 检查依赖-->
    <condition property="xalan.present">
          <and>
              <!-- No need to check all jars; just check a few -->
            <available classpathref="xslt.classpath" classname="org.apache.xalan.processor.TransformerFactoryImpl"/>
            <available classpathref="xslt.classpath" classname="org.apache.xml.serializer.ExtendedContentHandler"/>
          </and>
    </condition>

<target name="_message_xalan" unless="xalan.present">
          <echo>Cannot find all xalan and/or serialiser jars</echo>
        <echo>The XSLT formatting may not work correctly.</echo>
        <echo>Check you have xalan and serializer jars in ${lib.dir}</echo>
    </target>

</project>

jmeter的build.xml的更多相关文章

  1. ant+jmeter中build.xml配置详解

  2. 【ANT】运行JMeter用例的build.xml

    <?xml version="1.0" encoding="UTF-8"?> <!-- Licensed to the Apache Soft ...

  3. 通过ANT实现jmeter批量执行脚本、生成报告、发送邮件全套build.xml文件

    在开始通过ANT运行build.xml之前,有一步必须要做,那就是将JMeter所在目录下extras子目录里的ant-JMeter-1.1.1.jar复制到Ant所在目录lib子目录之下,这样Ant ...

  4. Ant构建原理及build.xml文档描述

    最近在改写jmeter,用到ant构建,记录一下. Ant的概念Make命令是一个项目管理工具,而Ant所实现功能与此类似.像make,gnumake和nmake这些编译工具都有一定的缺陷,但是Ant ...

  5. jmeter+ant生成xml报告

    1.jdk安装 2.jmter安装 3.ant安装 下载apache-ant-1.10.6-bin.zip,直接解压就可使用,和jmeter类似 ant环境变量配置 新建系统变量:ANT_HOME,变 ...

  6. java分享第二十天(build.xml的语法及写法)

    通常情况下,Ant构建文件build.xml应该在项目的基础目录.可以自由使用其他文件名或将构建文件中其他位置.在本练习中,创建一个名为build.xml 在电脑的任何地方的文件. <?xml ...

  7. Ant:build.xml 结构

     Ant build.xml 结构 project target task data property datatype v\:* {behavior:url(#default#VML);} o\:* ...

  8. 自动生成build.xml文件

    使用Eclipse 自动生成 Ant的Build.xml 配置文件,选择要生成Build.xml文件的项目,鼠标右键, Export-> General -> Ant Buildfiles ...

  9. Ant_的最完整build.xml解释

    Ant的概念 Make命令是一个项目管理工具,而Ant所实现功能与此类似.像make,gnumake和nmake这些编译工具都有一定的缺陷,但是Ant却克服了这些工具的缺陷.最初Ant开发者在开发跨平 ...

随机推荐

  1. Eclipse Git 插件 基本操作一【learn】

    安装GIT插件: 我的Eclipse版本为: Oxygen.2 Release (4.7.2),所以自带GIT插件,跳过安装. GIT插件配置: ①.添加好用户名和邮箱 注意下输入格式:user.na ...

  2. Shell简介:1分钟理解什么是Shell 脚本语言 解释器 以及编译器和编译语言

    Shell简介:1分钟理解什么是Shell 脚本语言 解释器 以及编译器和编译语言 现在我们使用的操作系统(Windows.Mac OS.Android.iOS 等)都是带图形界面的,简单直观,容易上 ...

  3. Java OOP——第七章 多线程

    1.进程:是指运行中的应用程序,每个进程都有自己独立的地址空间(内存空间): Eg:用户点击桌面的IE浏览器,就启动了一个进程,操作系统就会为该进程分配独立的地址空间.当用户再次点击左面的IE浏览器, ...

  4. 平衡二叉查找树 AVL 的实现

    不同结构的二叉查找树,查找效率有很大的不同(单支树结构的查找效率退化成了顺序查找).如何解决这个问题呢?关键在于如何最大限度的减小树的深度.正是基于这个想法,平衡二叉树出现了. 平衡二叉树的定义 (A ...

  5. .c和.h区别

    本质没有区别: .h是头文件 一般情况下下边内容放在.h文件中 宏定义 结构体,联合,枚举声明 typedef声明 外部函数声明 全局变量声明 .c是程序文件 一般情况下下边内容放在.h文件中 内含函 ...

  6. 1016-01-首页16-计算配图的frame----MJExtention的使用

    -------HWPhoto.h--------------------------------------------- #import <Foundation/Foundation.h> ...

  7. [USACO1.5] 回文质数

    P1217  Prime Palindromes 题目描述 因为151既是一个质数又是一个回文数(从左到右和从右到左是看一样的),所以 151 是回文质数. 写一个程序来找出范围[a,b](5 < ...

  8. C语言进阶——关于07中指针的补充

    首先我们应该了解指针可以分为: 野指针: 野指针不是NULL指针,是未初始化或未清零的指针,他指向的内存地址不是程序员想要的.人们一般不会错用NULL指针,因为用if语句很容易判断.但是“野指针”是很 ...

  9. 云心出岫——Splay Tree

    (多图预警!!!建议在WI-FI下观看) 之前我们谈论过AVL树,这是一种典型适度平衡的二叉搜索树,成立条件是保持平衡因子在[-1,1]的范围内,这个条件已经是针对理想平衡做出的一个妥协了,但依然显得 ...

  10. 笔记-DB-mongodb-常用操作-1

    笔记-DB-mongodb-常用操作-1 1.  启动及连接 1.1.  启动 启动mongod windows下: 1.   如已添加服务 net start <service name> ...