jmeter-- lightweight interface to automated testing framework

The general idea:

jmeter complete interface scripts, Ant complete script execution and collect the results to generate reports, and finally the use of automatic integrated operation jenkins completed script.

Environmental installation:
. 1, JDK installation configuration environment variable
2, jmeter zip package extract to a local, ant the zip package to extract local
3, Ant configure the environment variables
computer right - Properties - Advanced System Settings - Advanced - Environment Variables - System Variables
  ANT_HOME : ant decompression path
  path:% ANT_HOME% \ bin
  CALSSPATH: ANT_HOME% lib%;
4, cmd verify whether the installation was successful Ant
jmeter-- lightweight interface to automated testing framework
5, the next JMeter extras directory subdirectory of ant-JMeter-1.1.1.jar copy Ant lib directory to a subdirectory under
6, xls file a report template, put jmeter directory extras folder [jmeter comes with several sets of templates you can use to provide, in the kinds of extras subdirectory jmeter installation directory, xsl suffix]

7、创建如下测试脚本目录结构
jmeter_test(主目录文件)
 result(测试报告以及日志目录)
     --html  (测试报告目录)
         -jtl(存放jtl文件的目录)
 script(存放jmeter的jmx脚本文件)
 build.xml(核心配置文件)

 8、 build.xml核心配置文件,部分代码如下
 <?xml version="1.0" encoding="utf-8"?>

<. "" Project name = "QiangAPIJmeter1.0" default = "All" basedir =>
<tstamp>
<Property format = "Time" pattern = "yyyyMMddhhmm" />
</ tstamp>
<-! need to change their own local the Jmeter directory ->
<Property name = "jmeter.home" value = "D: \ Work_software \-JMeter Apache-3.3" />
! <- JMeter result report format generated jtl path ->
<Property name = "jmeter.result.jtl.dir" value = "D: \ Work_software \ jmeter Data \ jmeter_test \ result \ JTL" />
<- jmeter path generated html format results reported ->!
<Property name = " jmeter.result.html.dir "value =" D: \ Work_software \ JMeter Data \ jmeter_test \ Result \ HTML "/>
<- - prefix generator reports>!
the ReportName" <Property name = "value = "Lightweight Interface Test Report" />
<! - generating the various documents ->
<! - <Property name = "jmeter.result.jtlName" value = "$ {jmeter.result.jtl.dir } / $ {ReportName} .jtl " /> ->
<property name="jmeter.result.jtlName" value="${jmeter.result.jtl.dir}/${ReportName}${time}.jtl" />
<!--<property name="jmeter.result.htmlName" value="${jmeter.result.html.dir}/${ReportName}.html" />-->
<property name="jmeter.result.htmlName" value="${jmeter.result.html.dir}/${ReportName}${time}.html" />

<!-- 解决不显示 Min/Max 统计时间的问题。同时把下面的两个jar文件copy到ant的lib包中-->
<path id="xslt.classpath">
<fileset dir="${jmeter.home}/lib" includes="xalan-2.7.2.jar"/>
<fileset dir="${jmeter.home}/lib" includes="serializer-2.7.2.jar"/>
</path>

<target name="all">
    <antcall target="test" />
    <antcall target="report" />
</target>
<target name="test">
    <taskdef name="jmeter" classname="org.programmerplanet.ant.taskdefs.jmeter.JMeterTask" />
    <jmeter jmeterhome="${jmeter.home}" resultlog="${jmeter.result.jtlName}">
        <!-- 声明要运行的脚本。"*.jmx"指包含此目录下的所有jmeter脚本 -->
        <testplans dir="D:\Work_software\jmeter data\jmeter_test\script" includes="授权流程.jmx" />
    </jmeter>
</target>
<!-- jmeter生成的报告模板,在extras里-->
<target name="report">
    <!-- 解决不显示时间的问题-->
    <tstamp> <format property="report.datestamp" pattern="yyyy/MM/dd HH:mm" /></tstamp>
    <xslt in="${jmeter.result.jtlName}" out="${jmeter.result.htmlName}" style="${jmeter.home}/extras/jmeter-results-detail-report_xq1.xsl" >
    <param name="dateReport" expression="${report.datestamp}"/>
    </xslt>
    <!-- 因为上面生成报告的时候,不会将相关的图片一起拷贝至目标目录,所以,需要手动拷贝 -->
    <copy todir="${jmeter.result.html.dir}">
        <fileset dir="${jmeter.home}/extras">
            <include name="collapse.png" />
            <include name="expand.png" />
        </fileset>
    </copy>
</target>

</ project>
the operation switch to the directory 10.cmd jmeter_test directory, type ant execution latency, BUILD SUCCESSFUL appears
jmeter-- lightweight interface to automated testing framework
11. View Report
jmeter-- lightweight interface to automated testing framework
12, integrated into the step Jenkins about
12.1 System Manager -Global Tool Configuration, and arranged jdk ant
jmeter-- lightweight interface to automated testing framework
jmeter-- lightweight interface to automated testing framework
12.3 project build
12.3.1 New liberty style building tasks. Jenkins has been running the home page, click on the left side of the screen to enter the following New Job
jmeter-- lightweight interface to automated testing framework

jmeter-- lightweight interface to automated testing framework
12.3.2 increase build steps, ant Run
jmeter-- lightweight interface to automated testing framework
Ant Version Ant select the name of your configuration, be careful not to select the default
jmeter-- lightweight interface to automated testing framework
12.3.4 running OK

Guess you like

Origin blog.51cto.com/13729775/2415019