• jmeter+ant+jenkins接口自动环境搭建


    ant

    下载地址:http://archive.apache.org/dist/ant/binaries/

    下载:apache-ant-1.9.7-bin.zip

    解压到系统盘下:D:apache-ant-1.9.7-binapache-ant-1.9.7

    配置ant环境变量

             window中环境变量设置:

             path:D:apache-ant-1.9.7-binapache-ant-1.9.7in

    验证ant:cmd命令行输入:ant –version

             C:Userssfit1175>ant -version

    Apache Ant(TM) version 1.9.7 compiled on April 9 2016

    成功

    jmeter(2.11版本)

    1、将 jmeter的extras目录中ant-jmeter-1.1.1.jar包拷贝至ant安装目录下的lib目录中

    2、修改Jmeter的bin目录下jmeter.properties文件的配置:

    jmeter.save.saveservice.output_format=xml 

      3、jmeter 设置好脚本并保存(我的脚本目录:D:apache-jmeter-2.11demo)

    创建build.xml配置文件

             build.xml文件目录,放在与.jmx脚本同一个目录

             build.xml代码:

    <?xml version="1.0" encoding="UTF-8"?>

    <project name="ant-jmeter-test" default="run" basedir=".">

        <tstamp>

            <format property="time" pattern="yyyyMMddhhmm" />

        </tstamp>

        <!-- 需要改成自己本地的 Jmeter 目录--> 

        <property name="jmeter.home" value="D:apache-jmeter-2.11" />

        <!-- jmeter生成jtl格式的结果报告的路径-->

        <property name="jmeter.result.jtl.dir" value="D:apache-jmeter-2.11demo eportjtl" />

        <!-- jmeter生成html格式的结果报告的路径-->

        <property name="jmeter.result.html.dir" value="D:apache-jmeter-2.11demo eporthtml" />

        <!-- 生成的报告的前缀--> 

        <property name="ReportName" value="TestReport" />

        <property name="jmeter.result.jtlName" value="${jmeter.result.jtl.dir}/${ReportName}${time}.jtl" />

        <property name="jmeter.result.htmlName" value="${jmeter.result.html.dir}/${ReportName}${time}.html" />

       

        <target name="run">

            <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:apache-jmeter-2.11demo" includes="*.jmx" />

                <property name="jmeter.save.saveservice.output_format" value="xml"/>

            </jmeter>

        </target>

       

        <path id="xslt.classpath">

            <fileset dir="${jmeter.home}/lib" includes="xalan*.jar"/>

            <fileset dir="${jmeter.home}/lib" includes="serializer*.jar"/>

        </path>   

                   

        <target name="report">

                           <tstamp> <format property="report.datestamp" pattern="yyyy/MM/dd HH:mm" /></tstamp>

            <xslt

                  classpathref="xslt.classpath"

                  force="true"

                  in="${jmeter.result.jtlName}"

                  out="${jmeter.result.htmlName}"

                  style="${jmeter.home}/extras/jmeter-results-detail-report_21.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>

    ant运行脚本:

    1、  cmd命令行进入脚本目录

    2、  执行命令:ant 或ant run(run为build.xml中的task名),执行结果:

    D:apache-jmeter-2.11demo>ant

    Buildfile: D:apache-jmeter-2.11demouild.xml

    run:

    test:

       [jmeter] Executing test plan: D:apache-jmeter-2.11demo ead.jmx ==> D:apac

    he-jmeter-2.11demo eportjtlTestReport201605190320.jtl

       [jmeter] Creating summariser <summary>

       [jmeter] Created the tree successfully using D:apache-jmeter-2.11demo ead.

    jmx

       [jmeter] Starting the test @ Thu May 19 15:20:30 CST 2016 (1463642430955)

       [jmeter] Waiting for possible shutdown message on port 4445

       [jmeter] summary +      1 in   0.1s =   14.9/s Avg:    67 Min:    67 Max:

    67 Err:     0 (0.00%) Active: 6 Started: 6 Finished: 0

       [jmeter] summary +     99 in     1s =  125.5/s Avg:    53 Min:    12 Max:   1

    89 Err:     0 (0.00%) Active: 0 Started: 10 Finished: 10

       [jmeter] summary =    100 in     1s =  126.7/s Avg:    53 Min:    12 Max:   1

    89 Err:     0 (0.00%)

       [jmeter] Tidying up ...    @ Thu May 19 15:20:33 CST 2016 (1463642433497)

       [jmeter] ... end of run

    report:

         [xslt] Processing D:apache-jmeter-2.11demo eportjtlTestReport201605190

    320.jtl to D:apache-jmeter-2.11demo eporthtmlTestReport201605190320.html

         [xslt] Loading stylesheet D:apache-jmeter-2.11extrasjmeter-results-detai

    l-report_21.xsl

         [copy] Copying 2 files to D:apache-jmeter-2.11demo eporthtml

    BUILD SUCCESSFUL

    Total time: 5 seconds

    测试报告目录:D:apache-jmeter-2.11demo eporthtml

    jenkins集成

    1、  安装jenkins环境

    a)         下载地址:https://jenkins.io/index.html

    jenkins.war

    b)         windows下安装(JDK1.5版本以上环境)

    命令行切换到jenkins.war的根目录,输入 java -jar jenkins.war

    浏览器输入地址http://localhost:8080/显示界面,安装成功

    新建job

  • 相关阅读:
    利用栈计算后缀式
    中缀式转换为后缀式(逆波兰式)方法
    JAVA字符串首字母大小写转换(截取转换+移动ASCII编码)
    VSCode格式化代码后,设置代码不自动换行
    oracle连接不上,提示监听服务不可用的解决办法
    壹周立波秀
    欣慰,举手之力,帮助一个老同学恢复了博士论文文档
    开发中的思维转换也是一种创新-思维创新
    电脑借液晶电视显示器出现雪花点的另类解决办法
    邮箱已满解决办法
  • 原文地址:https://www.cnblogs.com/wnfindbug/p/5546789.html
Copyright © 2020-2023  润新知