没有合适的资源?快使用搜索试试~ 我知道了~
首页jenkins+ant+jmeter自动化接口测试框架搭建
jenkins+ant+jmeter自动化接口测试框架搭建
需积分: 48 1.1k 浏览量
更新于2023-03-16
评论 2
收藏 1.9MB PDF 举报
文档详细记录了jenkins+ant+jmeter自动化接口测试框架搭建的过程步骤,供大家参阅。
资源详情
资源评论
资源推荐

jenkins+ant+jmeter自动化接口测试框架搭建-V1.0.0
接口测试接口测试是测试中极为重要的环节,它所处的位置,有别于单元测试和功能测试,在单元测试之后,在功能测试
之前。每个接口都能代表某种功能,功能就有输入与输出。检验输入输出、各参数的取值以及异常情况,对于单元测试
来说,是一个补充,因为往往单元测试是以类、以方法来测试的。对于功能测试来说,是一个护盾,在经过接口测试的
验证后,能更高程度的保证功能点的正常执行。若能让接口定时测试或项目部署后自动进行验证(等同于回归测试),
显得极为方便、快捷,能更多地节省出时间,进行其他工作的进行。
基于以上的目的,搭建一套自动化接口测试框架显得尤为重要,在市面上测试接口的工具有很多,比如:LR、、
jmeter、、SoapUI、、Gatling、、Postman等等。打包构建的工具有Make、、Ant、、Maven等等。CI持续
集成的工具有Jenkins、、Hudson等等。这些工具各有千秋,只要能实现最初的目的,不管使用什么工具都是一个辅
助作用而已。而我选择的工具是Jenkins+Ant+Jmeter作为自动化接口测试框架的搭建。为啥使用这套框架是
由于最早时Jenkins上并没有maven插件,Jmeter设计打包构建测试的案例里用的就是Ant,基于以上背景,所以使用这套
工具有天然的成分在里面。
下面开始搭建这套框架的讲解。工欲善其事,必先利其器,在搭建之前,jenkins、ant、jmeter的linux版本包要准
备好。Java版本:版本:1.8.0_131;;Ant版本:版本:1.9.9;;Jenkins::2.65,并且都已安装至,并且都已安装至
Linux服务器上。环境变量设置如下:服务器上。环境变量设置如下:
在windows上打开Jmeter,把脚本编辑完成,能成功执行并返回结果。

在windos安装好Ant,新增其环境变量。

编辑Jmeter在这个目录下D:\Program Files (x86)\apache-jmeter-2.13\apache-jmeter-
2.13\extras的build.xml文件文件。因为ANT打包构建就是依赖这个文件做处理的,这文件如何编辑如下:
-----------------------------------------------------------------------------------------------------
-----------------
<?xml version="1.0" encoding="UTF8"?>
<!--
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">
<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 basedir).
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')
Deprecated:
-Dformat=2.0 - use version 2.0 JTL files rather than 2.1

</description>
<!-- 定义变量并赋值,能够减少配置工作量,后面会调用到-->
<!-- 定义jmeter的工作目录,与%JMETER_HOME%指向同一个目录-->
<!-- ${basedir}当前目录的意思,在此指向%JMETER_HOME%目录-->
<property name="jmeter.home" value="D:\Program Files (x86)\apache-jmeter-2.13\apache-jmeter-2.13"/>
<!-- 除了用basedir我们还可以用basedir来指定目录,这个指定的是%JMETER_HOME%-->
<!--property name="jmeter.home" value="${basedir}/.."/-->
<!--定义Jmeter的脚本存放目录,指向%JMETER_HOME%/script目录-->
<property name="script.dir" value="${jmeter.home}/script"/>
<!--定义Jmeter的测试结果存放目录,指向%JMETER_HOME%/result目录-->
<property name="jmeter.result" value="${jmeter.home}/result"/>
<!--定义测试报告的Title-->
<property name="report.title" value="Performance Test_Summary_Report"/>
<!--定义测试结果名称-->
<!-- Name of test (without .jmx) -->
<property name="test" value="Test"/>
<!--测试报告中是否显示失败事务,n为不显示-->
<!-- Should report include response data for failures? -->
<property name="show-data" value="n"/>
<!--定义样式版本,有更新时只需要修改此处即可,其他调用处不用更改-->
<property name="format" value="2.1"/>
<condition property="style_version" value="">
<equals arg1="${format}" arg2="2.0"/>
</condition>
<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结尾的包都引入进来,在此*一般是版本信息-->
<!--在此*一般是版本信息,我们使用的Jmeter中是ant-jmeter-1.1.1.jar-->
<include name="ant-jmeter*.jar"/>
</fileset>
</path>
剩余16页未读,继续阅读










安全验证
文档复制为VIP权益,开通VIP直接复制

评论0