有两个插件能够实现在Maven build集成Jmeter测试, jmeter-maven-plugin 和 chronos-maven-plugin. 选择哪一个取决于情况,下面是一些判断标准:

  1. 该插件不应该依赖于本地JMeter的安装。
  2. 它必须能够从命令行启动JMeter测试(无GUI)。
  3. JMeter的图形用户界面也应该通过插件(例如,通过一个单独的Maven目标)直接实现。
  4. 它包含JMeter的插件。
  5. 该插件应该产生有意义的报告。

第一第二条两个都满足,jmeter-maven-plugin可以在无图形情况下使用一个简单的附加依赖项kg.apc:jmeter-plugins直接使用使用JMeter,这点是 jmeter-chronos-maven-plugin没有的。

下面是一段来自 jmeter-maven-example的配置:

<plugin>
  <groupId>com.lazerycode.jmeter</groupId>
  <artifactId>jmeter-maven-plugin</artifactId>
  <version>1.8.1</version>
  <configuration>
    <!--
       By default the test results are saved in a file 
       /target/jmeter/results/<testname>-<timestamp>.jtl
       Further processing is easier without timestamp though.
    -->
    <testResultsTimestamp>false</testResultsTimestamp>
 
    <!--
       To simplify debugging, it is advisable to adapt the loglevel.
       The jmeter logs are written to the file jmeter.log.
    -->
    <overrideRootLogLevel>DEBUG</overrideRootLogLevel>
 
    <!--
       By default, the console output during a jmeter test run is suppressed.
       We want to display the progress using the listener "Generate Summary Results"
       (which periodically prints stats to stdout). Therefore we have to make sure,
       that the jmeter output is not suppressed.
    -->
    <suppressJMeterOutput>false</suppressJMeterOutput>
 
    <!--
       If tests fail (e.g. a http-request running into a timeout), the corresponding maven
       goal also fails (and subsequent goals aren't executed anymore). We want to create graphs
       from test-results, no matter if some requests failed or not, so we ignore jmeter failures.
    -->
    <ignoreResultFailures>true</ignoreResultFailures>
  </configuration>
  <dependencies>
    <dependency>
      <groupId>kg.apc</groupId>
      <artifactId>jmeter-plugins</artifactId>
      <version>1.0.0</version>
      <exclusions>
         <!--
            Unfortunately some transitive dependencies cannot be found on mvncentral
            and we have to explicitly exclude them.
            For a complete list, see https://github.com/mlex/jmeter-maven-example/
        -->
        <exclusion>
            <groupId>kg.apc</groupId>
            <artifactId>perfmon</artifactId>
        </exclusion>
        <!-- ... -->
 
        <!--
            Because of a bug in the jmeter-maven-plugin (see
            https://github.com/Ronnie76er/jmeter-maven-plugin/issues/77) we have to
            exclude jmeter dependencies here, too.
        -->
        <exclusion>
            <groupId>org.apache.jmeter</groupId>
            <artifactId>jorphan</artifactId>
        </exclusion>
        <!-- ... -->
      </exclusions>
    </dependency>
  </dependencies>
</plugin>

这个测试文件必须放在 /src/test/jmeter,您可以编辑和执行测试。

测试环境可以是各种,这里结合 Jenkins中创建一个Job,允
许一次点击就可以执行JMeter的测试,首先要使用Maven的属性和配置文件。下面示例项目中定义了两种不同的Maven配置文件,一个用于本地执
行,一个用于从jenkins执行。 Maven的特性是通过userProperties选项传递到JMeter的。

<profiles>
  <profile>
    <id>local</id>
    <properties>
      <performancetest.webservice.host>localhost</performancetest.webservice.host>
      <performancetest.webservice.port>8080</performancetest.webservice.port>
    </properties>
  </profile>
  <profile>
    <id>jenkins</id>
    <properties>
      <performancetest.webservice.host>my.test.system</performancetest.webservice.host>
      <performancetest.webservice.port>80</performancetest.webservice.port>
    </properties>
  </profile>
  <build>
    <plugins>
      <plugin>
        <groupId>com.lazerycode.jmeter</groupId>
        <artifactId>jmeter-maven-plugin</artifactId>
        <version>1.8.1</version>
        <configuration>
          <propertiesUser>
            <webservice.host>${performancetest.webservice.host}</webservice.host>
            <webservice.port>${performancetest.webservice.port}</webservice.port>
          </propertiesUser>
        </configuration>
      </plugin>
    </plugins>
  </build>
</plugin>

使用Jenkins-CI进行JMeter tests

  现在,我们已经为各种环境下制作了不同的Maven配置文件,一个合适的jenkins作业的配置仅仅需要一小步。参数化的构建版
本是jenkins的另一个不错的功能,针对JMeter的测试非常有用。参数可用于例如,允许用户定义负载测试的大小(即:线程数和迭代的次数)。

报表

使用jmeter-graph-maven-plugin集合Jmeter的CMDRunner工具,可以让我们在Maven Build中输出图形结果。

https://github.com/codecentric/jmeter-graph-maven-plugin

使用Maven Jenkins和JMeter自动化测试的更多相关文章

  1. Jenkins+Ant+Jmeter自动化测试平台

            持续集成 持续集成是一种软件开发实践,即团队开发成员经常集成他们的工作,通常每个成员每天至少集成一次,也就意味着每天可能会发生多次集成.每次集成都通过自动化的构建(包括编译,发布,自动 ...

  2. 基于Jmeter+maven+Jenkins构建性能自动化测试平台

      一.目的: 为能够将相关系统性能测试做为常规化测试任务执行,且可自动无人值守定时执行并输出性能测试结果报告及统计数据,因此基于Jmeter+maven+Jenkins构建了一套性能自动化测试平台 ...

  3. Jmeter +Maven+jenkins+eclipse 接口自动化测试

    背景: 首先用jmeter录制或者书写性能测试的脚本,用maven添加相关依赖,把性能测试的代码提交到github,在jenkins配置git下载性能测试的代码,配置运行脚本和测试报告,配置运行失败自 ...

  4. Jenkins +Ant +Jmeter(apache-jmeter-5.1.1)自动化性能测试平台

    1.安装配置好Jdk, 下载网址:https://www.cr173.com/soft/33894.html 2.Jmeter下载地址:http://jmeter.apache.org/downloa ...

  5. Maven jenkins +Jmeter自动化测试

    Maven jenkins +Jmeter自动化测试 1. Jenkins中集成jmeter-maven插件 http://my.oschina.net/u/1377774/blog/168969 2 ...

  6. 自动化测试框架:jmeter + maven+ jenkins

    原理:jenkins驱动maven执行,maven驱动jmeter执行 前提条件:windows安装了jmeter.maven.tomcat.jenkins 安装方法参考汇总目录中对应的博文:http ...

  7. jmeter+maven+jenkins自动化接口测试(下)

    maven+jmeter已经写好了,可以通过maven来执行jmeter的接口测试脚本,怎样实现定时执行测试并发送报告邮件就需要通过jenkins了(jmeter或者testng也可以结合不同的邮件j ...

  8. Jmeter+maven+Jenkins构建云性能测试平台(mark 推荐)

    转自:http://www.cnblogs.com/victorcai0922/archive/2012/06/20/2555502.html Jmeter+maven+Jenkins构建云性能测试平 ...

  9. 七、Jmeter + ant + jenkins轻量级接口自动化测试

    七.Jmeter + ant + jenkins轻量级接口自动化测试 杀猪不用牛刀,工具没有牛逼高大尚之分,每个工具都有存在的理由:关键是看会不会用,怎么用,有没有用在合适的地方. 需要安装的工具: ...

随机推荐

  1. HttpContext.Current.Session 和 Session 的区别

    Session(会话)通常指一个动作从开始到结束不间断的一个动作. 例如“打电话”,通常是“1.拿起电话--2.拨对方号码--3.对方截图--4.挂机”.这四个步骤从完成到结束组成了一个基本的Sess ...

  2. iOS:移动端“用户反馈和客服”的几个平台SDK的介绍

    简单阐述: 用户反馈功能几乎是每个app都有的一个功能点,通过反馈功能实现与用户的连接.沟通,随时随地收集用户意见反馈和Bug报告,即时和用户保持沟通,在一定程度上提升了app的竞争力.而给app评分 ...

  3. Windows7安装CodeTyphon

    WARNING 1: On windows (XP, Vista and Win7), you must install this software as user with administrato ...

  4. LeetCode 754. Reach a Number到达终点数字

    题目 在一根无限长的数轴上,你站在0的位置.终点在target的位置. 每次你可以选择向左或向右移动.第 n 次移动(从 1 开始),可以走 n 步. 返回到达终点需要的最小移动次数. 示例 1: 输 ...

  5. 如何统计NFS的client在一段时间内收到了多少个字节?

    可使用的命令如下: nfsstat –c nfsiostat 参考资料 ============= https://www.systutorials.com/docs/linux/man/8-nfss ...

  6. 记录Activity启动时间 ActivityLifecycleCallbacks

    ActivityStackManager 定义一个集合(Stack)保存所有还未销毁的 Activity public class ActivityStackManager { private Sta ...

  7. 大数据开发实战:Hive优化实战3-大表join大表优化

    5.大表join大表优化 如果Hive优化实战2中mapjoin中小表dim_seller很大呢?比如超过了1GB大小?这种就是大表join大表的问题.首先引入一个具体的问题场景,然后基于此介绍各自优 ...

  8. 梯度消失(vanishing gradient)与梯度爆炸(exploding gradient)问题

    (1)梯度不稳定问题: 什么是梯度不稳定问题:深度神经网络中的梯度不稳定性,前面层中的梯度或会消失,或会爆炸. 原因:前面层上的梯度是来自于后面层上梯度的乘乘积.当存在过多的层次时,就出现了内在本质上 ...

  9. 用Maven构建单机Mahout项目

    Hadoop家族系列文章,主要介绍Hadoop家族产品,常用的项目包括Hadoop, Hive, Pig, HBase, Sqoop, Mahout, Zookeeper, Avro, Ambari, ...

  10. 【大数据】MongoDB安装(转)

    https://note.youdao.com/share/?id=40be7f77434910e8860c5fd1ef5d24fe&type=note#/ MongoDB安装 环境 Cent ...