zoukankan      html  css  js  c++  java
  • ant+jmeter环境配置

    (1)解压ant、jmeter安装包,最好解压至同一个目录下

    (2)配置jdk、ant

    ant环境配置:

    ANT_HOME:C:apache-ant-1.9.13

    CLASSPATH:C:apache-ant-1.9.13lib

    Path:C:apache-ant-1.9.13in

    (3)解压ant_demo至jmeter目录下

    (4)修改配置文件/jmeter/bin/jmeter.properties,去掉“#”,将jmeter.save.saveservice.output_format=csv修改为jmeter.save.saveservice.output_format=xml

     

    (5)将/jmeter/extras/ant-jmeter-1.1.1文件拷贝至/ant/lib/下

     (6)修改apache-jmeter/ant_demo/build文件内容(build从其他地方拷贝过来)

     1 <?xml version="1.0" encoding="UTF8"?>
     2 
     3 <project name="Jmeter-TestCase" default="run" basedir=".">
     4 <tstamp>
     5 <format property="time" pattern="yyyyMMddhhmm" />
     6 </tstamp>
     7 
     8 <!--jmeter的目录-->
     9 <property name="jmeter.home" value="C:apache-jmeter-4.0" />
    10 <property name="jmeter.result.jtl.dir" value="C:apache-jmeter-4.0ant_demo
    esultLogjtl" />
    11 <property name="jmeter.result.html.dir" value="C:apache-jmeter-4.0ant_demo
    esultLoghtml" />
    12 
    13 <property name="ReportName" value="TestReport" />
    14 <property name="jmeter.result.jtlName" value="${jmeter.result.jtl.dir}/${ReportName}${time}.jtl" />
    15 <property name="jmeter.result.htmlName" value="${jmeter.result.html.dir}/${ReportName}${time}.html" />
    16 
    17 <target name="run">
    18 <antcall target="test" />
    19 <antcall target="report" />
    20 </target>
    21 
    22 <target name="test">
    23 <taskdef name="jmeter" classname="org.programmerplanet.ant.taskdefs.jmeter.JMeterTask" />
    24 <jmeter jmeterhome="${jmeter.home}" resultlog="${jmeter.result.jtlName}">
    25 <testplans dir="C:apache-jmeter-4.0ant_demoscript" includes="Test.jmx" />
    26 <property name="jmeter.save.saveservice.output_format" value="xml"/>
    27 </jmeter>
    28 </target>
    29 
    30 
    31 
    32 <target name="report">
    33 <xslt in="${jmeter.result.jtlName}"
    34 out="${jmeter.result.htmlName}"
    35 style="${jmeter.home}/extras/jmeter-results-detail-report_21.xsl" />
    36 <copy todir="${jmeter.result.html.dir}">
    37 <fileset dir="${jmeter.home}/extras">
    38 <include name="collapse.png" />
    39 <include name="expand.png" />
    40 </fileset>
    41 </copy>
    42 </target>
    43 
    44 </project>
    View Code

    jmeter的安装目录及运行脚本后生成的结果目录

    1      <!--jmeter的目录-->
    2      <property name="jmeter.home" value="C:apache-jmeter-4.0" />
    3      <property name="jmeter.result.jtl.dir" value="C:apache-jmeter-4.0ant_demo
    esultLogjtl" />
    4      <property name="jmeter.result.html.dir" value="C:apache-jmeter-4.0ant_demo
    esultLoghtml" />
    View Code

    jmeter运行脚本后生成的文件名称

    1      <property name="ReportName" value="TestReport" />
    2      <property name="jmeter.result.jtlName" value="${jmeter.result.jtl.dir}/${ReportName}${time}.jtl" />
    3      <property name="jmeter.result.htmlName" value="${jmeter.result.html.dir}/${ReportName}${time}.html" />
    View Code

    jmeter所运行的脚本

    1    <target name="test">
    2          <taskdef name="jmeter" classname="org.programmerplanet.ant.taskdefs.jmeter.JMeterTask" />
    3          <jmeter jmeterhome="${jmeter.home}" resultlog="${jmeter.result.jtlName}">
    4             <testplans dir="C:apache-jmeter-4.0ant_demoscript" includes="Test.jmx" />
    5              <property name="jmeter.save.saveservice.output_format" value="xml"/>
    6          </jmeter>
    7      </target>
    View Code

    (7)打开cmd,切换至jmeter/ant_demo目录下执行ant,至此搭建完成

     1 C:apache-jmeter-4.0ant_demo>ant
     2 Buildfile: C:apache-jmeter-4.0ant_demouild.xml
     3 
     4 run:
     5 
     6 test:
     7    [jmeter] Executing test plan: C:apache-jmeter-4.0ant_demoscriptTest.jmx =
     8 => C:apache-jmeter-4.0ant_demo
    esultLogjtlTestReport201808230105.jtl
     9    [jmeter] 八月 23, 2018 1:05:05 下午 java.util.prefs.WindowsPreferences <init>
    10 
    11    [jmeter] 警告: Could not open/create prefs root node SoftwareJavaSoftPrefs
    12 at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.
    13    [jmeter] Creating summariser <summary>
    14    [jmeter] Created the tree successfully using C:apache-jmeter-4.0ant_demosc
    15 riptTest.jmx
    16    [jmeter] Starting the test @ Thu Aug 23 13:05:06 CST 2018 (1535000706846)
    17    [jmeter] Waiting for possible Shutdown/StopTestNow/Heapdump message on port 4
    18 445
    19    [jmeter] summary =     40 in 00:00:03 =   12.6/s Avg:   232 Min:   107 Max:
    20  358 Err:     2 (5.00%)
    21    [jmeter] Tidying up ...    @ Thu Aug 23 13:05:11 CST 2018 (1535000711613)
    22    [jmeter] ... end of run
    23 
    24 report:
    25      [xslt] Processing C:apache-jmeter-4.0ant_demo
    esultLogjtlTestReport201
    26 808230105.jtl to C:apache-jmeter-4.0ant_demo
    esultLoghtmlTestReport20180823
    27 0105.html
    28      [xslt] Loading stylesheet C:apache-jmeter-4.0extrasjmeter-results-detail
    29 -report_21.xsl
    30      [copy] Copying 2 files to C:apache-jmeter-4.0ant_demo
    esultLoghtml
    31 
    32 BUILD SUCCESSFUL
    33 Total time: 9 seconds
    View Code
  • 相关阅读:
    ToString格式化
    [转]vc中socket编程步骤
    [XAML学习资料] 验证用户提供的数据ValidationRule
    VS2008下安装boost
    [ASP.NET用户验证一]Forms验证
    VISTA IIS Worker Process 已停止工作 解决办法
    [MFC入门二]四种不同对象
    删除TFS项目
    [WPF学习资料] WPF简介
    IIS7下配置PHP5
  • 原文地址:https://www.cnblogs.com/zhuangshi/p/9525744.html
Copyright © 2011-2022 走看看