摘要:了解.jmx文件格式类型,对jmeter二次开发与拓展有很大的帮助,当然也可以利用python对其进行一些处理(生成一些测试用例,对jmx文件进行 ”增删改查“)。

一个完整用例的.jmx文件基本结构是这样,类似于xml结构(树状结构)(文章标红处 均是 可以修改的 地方(也可以说就是一个可控变量));

python 处理xml文件的模块,bs4 , xml.dom;

下面按结构自上而下讲解各个部分再.jmx文件中的表示:

测试计划  root

<TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="测试计划" enabled="true">
<stringProp name="TestPlan.comments"></stringProp>
<boolProp name="TestPlan.functional_mode">false</boolProp>
<boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
<elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="用户定义的变量" enabled="true">
<collectionProp name="Arguments.arguments"/>
</elementProp>
<stringProp name="TestPlan.user_define_classpath"></stringProp>
</TestPlan>

变量包含: testname, enabled(true启用,false禁用)

线程组  first Child

<ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="组织架构管理_业务场景测试" enabled="true">
<stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
<elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="循环控制器" enabled="true">
<boolProp name="LoopController.continue_forever">false</boolProp>
<stringProp name="LoopController.loops">1</stringProp> -- 循环一次
</elementProp>
<stringProp name="ThreadGroup.num_threads">1</stringProp> -- 线程数1
<stringProp name="ThreadGroup.ramp_time">1</stringProp>   -- Ramp-up Time =1,启动时间
<longProp name="ThreadGroup.start_time">1472796674000</longProp>
<longProp name="ThreadGroup.end_time">1472796674000</longProp>
<boolProp name="ThreadGroup.scheduler">false</boolProp>
<stringProp name="ThreadGroup.duration"></stringProp>
<stringProp name="ThreadGroup.delay"></stringProp>
</ThreadGroup>

JDBCDataSource

<JDBCDataSource guiclass="TestBeanGUI" testclass="JDBCDataSource" testname="数据库连接信息配置" enabled="true">
<boolProp name="autocommit">true</boolProp>
<stringProp name="checkQuery">Select 1</stringProp>
<stringProp name="connectionAge">5000</stringProp>  -- 最大连接age
<stringProp name="dataSource">mysql</stringProp>  -- 资源池变量
<stringProp name="dbUrl">jdbc:mysql://localhost/db</stringProp>  --jdbc连接
<stringProp name="driver">com.mysql.jdbc.Driver</stringProp>  -- jdbc驱动(可以设置为常量)
<boolProp name="keepAlive">true</boolProp>
<stringProp name="password">root</stringProp>  -- db密码
<stringProp name="poolMax">10</stringProp>  -- 最大连接数
<stringProp name="timeout">10000</stringProp>
<stringProp name="transactionIsolation">DEFAULT</stringProp>
<stringProp name="trimInterval">60000</stringProp>
<stringProp name="username">name</stringProp>  -- 用户名
</JDBCDataSource>

HTTP请求默认值

   <ConfigTestElement guiclass="HttpDefaultsGui" testclass="ConfigTestElement" testname="HTTP请求默认值" enabled="true">
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="用户定义的变量" enabled="true">
<collectionProp name="Arguments.arguments"/>
</elementProp>
<stringProp name="HTTPSampler.domain">host</stringProp>  -- host 服务器IP
<stringProp name="HTTPSampler.port">port</stringProp>  -- port端口
<stringProp name="HTTPSampler.connect_timeout">100000</stringProp>  -- 连接超时时间
<stringProp name="HTTPSampler.response_timeout">100000</stringProp>  -- 请求超时时间
<stringProp name="HTTPSampler.protocol">http</stringProp>  -- 协议类型(变量可填)
<stringProp name="HTTPSampler.contentEncoding">utf-8</stringProp>
<stringProp name="HTTPSampler.path"></stringProp>
<stringProp name="HTTPSampler.implementation">HttpClient4</stringProp>  -- 可选择(java\HttpCliet4)
<stringProp name="HTTPSampler.concurrentPool">4</stringProp>
</ConfigTestElement>

HTTP信息头管理器(http请求头设置,key-value对应)

        <HeaderManager guiclass="HeaderPanel" testclass="HeaderManager" testname="HTTP信息头管理器" enabled="true">
<collectionProp name="HeaderManager.headers">
<elementProp name="" elementType="Header">
<stringProp name="Header.name">Content-Type</stringProp>
<stringProp name="Header.value">application/json</stringProp>
</elementProp>
</collectionProp>
</HeaderManager>

用户定义的变量

  <Arguments guiclass="ArgumentsPanel" testclass="Arguments" testname="用户定义的变量" enabled="true">
<collectionProp name="Arguments.arguments">
<elementProp name="accessToken" elementType="Argument">
<stringProp name="Argument.name">accessToken</stringProp>
<stringProp name="Argument.value">${accessToken}</stringProp>
<stringProp name="Argument.metadata">=</stringProp>
<stringProp name="Argument.desc">description</stringProp>
</elementProp>
</collectionProp>
</Arguments>

仅一次控制器(循环控制器)

        <OnceOnlyController guiclass="OnceOnlyControllerGui" testclass="OnceOnlyController" testname="组织管理" enabled="true"/>

查看结果树(该部分为固定项)

         <ResultCollector guiclass="ViewResultsFullVisualizer" testclass="ResultCollector" testname="察看结果树" enabled="true">
<boolProp name="ResultCollector.error_logging">false</boolProp>
<objProp>
<name>saveConfig</name>
<value class="SampleSaveConfiguration">
<time>true</time>
<latency>true</latency>
<timestamp>true</timestamp>
<success>true</success>
<label>true</label>
<code>true</code>
<message>true</message>
<threadName>true</threadName>
<dataType>true</dataType>
<encoding>false</encoding>
<assertions>true</assertions>
<subresults>true</subresults>
<responseData>false</responseData>
<samplerData>false</samplerData>
<xml>false</xml>
<fieldNames>false</fieldNames>
<responseHeaders>false</responseHeaders>
<requestHeaders>false</requestHeaders>
<responseDataOnError>false</responseDataOnError>
<saveAssertionResultsFailureMessage>false</saveAssertionResultsFailureMessage>
<assertionsResultsToSave>0</assertionsResultsToSave>
<bytes>true</bytes>
<url>true</url>
<hostname>true</hostname>
<threadCounts>true</threadCounts>
<sampleCount>true</sampleCount>
</value>
</objProp>
<stringProp name="filename"></stringProp>
</ResultCollector>

HTTP请求(Sampler,此处为Json写法,因为请求类型为Application/Json)

<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="operatorLogin_操作员登录" enabled="true">
<boolProp name="HTTPSampler.postBodyRaw">true</boolProp>
<elementProp name="HTTPsampler.Arguments" elementType="Arguments">
<collectionProp name="Arguments.arguments">
<elementProp name="" elementType="HTTPArgument">
<boolProp name="HTTPArgument.always_encode">false</boolProp>
<stringProp name="Argument.value">{&quot;operatorNo&quot;:&quot;${operatorNo}&quot;, &quot;password&quot;:&quot;${password}&quot;, &quot;verifyCode&quot;:&quot;${verifyCode}&quot;}</stringProp>
<stringProp name="Argument.metadata">=</stringProp>
</elementProp>

</collectionProp>
</elementProp>
<stringProp name="HTTPSampler.domain"></stringProp>
<stringProp name="HTTPSampler.port"></stringProp>
<stringProp name="HTTPSampler.connect_timeout"></stringProp>
<stringProp name="HTTPSampler.response_timeout"></stringProp>
<stringProp name="HTTPSampler.protocol"></stringProp>
<stringProp name="HTTPSampler.contentEncoding"></stringProp>
<stringProp name="HTTPSampler.path">/operatorLogin</stringProp>   -- 请求路径
<stringProp name="HTTPSampler.method">POST</stringProp>
<boolProp name="HTTPSampler.follow_redirects">true</boolProp>
<boolProp name="HTTPSampler.auto_redirects">false</boolProp>
<boolProp name="HTTPSampler.use_keepalive">true</boolProp>
<boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
<boolProp name="HTTPSampler.monitor">false</boolProp>
<stringProp name="HTTPSampler.embedded_url_re"></stringProp>
</HTTPSamplerProxy>

响应断言

<ResponseAssertion guiclass="AssertionGui" testclass="ResponseAssertion" testname="响应断言" enabled="true">
<collectionProp name="Asserion.test_strings">
<stringProp name="-1610171759">&quot;errorCode&quot;:&quot;0&quot;,&quot;errorMsg&quot;:&quot;操作成功!&quot;</stringProp>
</collectionProp>
<stringProp name="Assertion.test_field">Assertion.response_data</stringProp>
<boolProp name="Assertion.assume_success">false</boolProp>
<intProp name="Assertion.test_type">2</intProp>
<stringProp name="Assertion.scope">all</stringProp>
<stringProp name="Scope.variable">count_1</stringProp>
</ResponseAssertion>

Debuger Sampler(固定样式)

  <DebugSampler guiclass="TestBeanGUI" testclass="DebugSampler" testname="Debug Sampler" enabled="true">
<boolProp name="displayJMeterProperties">false</boolProp>
<boolProp name="displayJMeterVariables">true</boolProp>
<boolProp name="displaySystemProperties">false</boolProp>
</DebugSampler>

JMeter测试工具.jmx文件详解的更多相关文章

  1. Web性能压力测试工具之Siege详解

    PS:Siege是一款开源的压力测试工具,设计用于评估WEB应用在压力下的承受能力.可以根据配置对一个WEB站点进行多用户的并发访问,记录每个用户所有请求过程的相应时间,并在一定数量的并发访问下重复进 ...

  2. IO测试工具之fio详解

    目前主流的第三方IO测试工具有fio.iometer和Orion,这三种工具各有千秋. fio在Linux系统下使用比较方便,iometer在window系统下使用比较方便,Orion是oracle的 ...

  3. IO测试工具之fio详解(转)

    http://www.cnblogs.com/raykuan/p/6914748.html 目前主流的第三方IO测试工具有fio.iometer和Orion,这三种工具各有千秋. fio在Linux系 ...

  4. Web 性能压力测试工具之 Siege 详解

    Siege是一款开源的压力测试工具,设计用于评估WEB应用在压力下的承受能力.可以根据配置对一个WEB站点进行多用户的并发访问,记录每个用户所有请求过程的相应时间,并在一定数量的并发访问下重复进行.s ...

  5. (总结)Web性能压力测试工具之WebBench详解

      PS:在运维工作中,压力测试是一项很重要的工作.比如在一个网站上线之前,能承受多大访问量.在大访问量情况下性能怎样,这些数据指标好坏将会直接影响用户体验.但是,在压力测试中存在一个共性,那就是压力 ...

  6. Web性能压力测试工具之WebBench详解

    PS:在运维工作中,压力测试是一项很重要的工作.比如在一个网站上线之前,能承受多大访问量.在大访问量情况下性能怎样,这些数据指标好坏将会直接影响用户体验.但是,在压力测试中存在一个共性,那就是压力测试 ...

  7. Protobuf 文件生成工具 Prototool 命令详解

    Protobuf 文件生成工具 Prototool 命令详解 简介 Prototool 是 Protobuf 文件的生成工具, 目前支持go, php, java, c#, object c 五种语言 ...

  8. Apache性能测试工具ab使用详解~转载

    Apache自带性能测试工具ab使用详解 一. Apache的下载 1. http://www.apache.org/,进入Apache的官网 2. 将页面拖到最下方“Apache Project L ...

  9. Linux中/proc目录下文件详解

    转载于:http://blog.chinaunix.net/uid-10449864-id-2956854.html Linux中/proc目录下文件详解(一)/proc文件系统下的多种文件提供的系统 ...

随机推荐

  1. 【js语法】array

    array操作说明 链接:http://www.w3school.com.cn/jsref/jsref_obj_array.asp 函数说明: concat():把两个array连接起来 join() ...

  2. 844. Backspace String Compare判断删除后的结果是否相等

    [抄题]: Given two strings S and T, return if they are equal when both are typed into empty text editor ...

  3. 单击Gridview中LinkButton,获取当前行索引及某单元格值,进行相关处理

    1.在Gridview中添加模板列,在其中加入Linkbuttion,增加CommandName属性 (设置命令名),并赋值 <asp:TemplateField HeaderText=&quo ...

  4. git 本地仓库与远程仓库的连接

    在远程如github新建一个项目名称为blog, 本地项目为store,是一个laravel框架项目,首先用 git init初始化本目,然后用git remote add origin git@gi ...

  5. hdu 1072(BFS) 有炸弹

    http://acm.hdu.edu.cn/showproblem.php?pid=1072 题目大意是在一个n×m的地图上,0表示墙,1表示空地,2表示人,3表示目的地,4表示有定时炸弹重启器. 定 ...

  6. CH6202 黑暗城堡

    一道最短路+生成树 原题链接 实际上就是生成树的中每个点到节点\(1\)的距离等于原图中这个点到节点\(1\)的最短距离,求这样的生成树的棵数. 先用\(SPFA\)或\(Dijkstra\)求出所有 ...

  7. [线段树]picture

    PICTURE 题目描述 N(N<5000) 张矩形的海报,照片和其他同样形状的图片贴在墙上.它们的边都是垂直的或水平的.每个矩形可以部分或者全部覆盖其他矩形.所有的矩形组成的集合的轮廓称为周长 ...

  8. 开发中,android手机WIFI无法使用,无SIM卡故障解决

    用eclipse 开发android中,突然出现,android手机WIFI无法使用,无SIM卡故障解决 发现故障后,想办法刷机(没有成功),触点清洁都搞了. 最后恢复出厂设置居然解决了,留资料给同行 ...

  9. RPDU

    RPDU(Remote Power Distribution Unit) 又称网络电源控制系统.远程电源管理系统.智能PDU.智能电源分配系统,是由傲视恒安科技(北京)有限公司自主研发生产并在全国范围 ...

  10. SQL语句的三大类

    数据定义语言(DDL Data Defination Language):用于创建和定义数据库对象,并且将对这些对象的定义保存到数据库字典中,通过DDL语句可以创建数据库对象.修改数据库对象.删除数据 ...